+ Reply to Thread
Results 1 to 9 of 9

Reopen "Adding days to date" - Level Up

Hybrid View

  1. #1
    Registered User
    Join Date
    10-26-2012
    Location
    Gdansk, Poland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Reopen "Adding days to date" - Level Up

    Hi,

    I just wanted to reopen my case by adding another command.
    As a reminder, I am cerating a user form that adds number of days to a date.
    Let's say i have 3 TextBoboxes (TB1 - Date, TB-2 number of days, TB-3Target date).
    for example today is 10/29/12. i want to add 70 days to today and get the result in TB3.

    Now i would like to add another command that would calculate working days only (exluding Sat and Sun)

    So far Sindhus advised using the following:

    Tb3.value = DateAdd("d", TB2.Value, Tb1.Value)

    it works 100% correct but what it would have to look like for counting working days only?

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    08-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    573

    Re: Reopen "Adding days to date" - Level Up

    how about tb3.value = worksheetfunction.WorkDay(Tb1.value,tb2.value)

  3. #3
    Registered User
    Join Date
    10-26-2012
    Location
    Gdansk, Poland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Reopen "Adding days to date" - Level Up

    57704 - this what i get when i add 7 days from today
    I guess the number is correct but it should be somehow converted to date...

  4. #4
    Valued Forum Contributor
    Join Date
    08-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    573

    Re: Reopen "Adding days to date" - Level Up

    Then try
    tb3.value = format(worksheetfunction.WorkDay(Tb1.value,tb2.value),"mm/dd/yyyy")

  5. #5
    Registered User
    Join Date
    10-26-2012
    Location
    Gdansk, Poland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Reopen "Adding days to date" - Level Up

    2057-12-21.... not really...

  6. #6
    Valued Forum Contributor
    Join Date
    08-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    573

    Re: Reopen "Adding days to date" - Level Up

    What is the format of your date in tb1.value?

  7. #7
    Registered User
    Join Date
    10-26-2012
    Location
    Gdansk, Poland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Reopen "Adding days to date" - Level Up

    2012-10-29
    already tried mm/dd/yyyy, yyyy-mm-dd, yyyy/mm/dd and many others. maybe the problem is with TB2 (the number of days) is there a function that would treat the number as days and not years or months instead?

  8. #8
    Valued Forum Contributor
    Join Date
    08-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    573

    Re: Reopen "Adding days to date" - Level Up

    No the problem is with tb1 only. I have formatted tb1 in the code. check this.
    tb3.value = format(worksheetfunction.WorkDay(format(Tb1.value,"mm/dd/yyyy"),tb2.value),"mm/dd/yyyy")

  9. #9
    Registered User
    Join Date
    10-26-2012
    Location
    Gdansk, Poland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Reopen "Adding days to date" - Level Up

    i just changed the last format to yyyy/mm/dd and it is perfect now. thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1