Problem Calculating Dates

1. Srikanth Kantheti Guest

## Problem Calculating Dates

Problem: For eg., I am planning to start a work on 14th March 2001 and it is going to take 45 days. Now i want the ending date when work will be finished . Problem is that i had to exclude weekends like saturdays and sundays and i want the end date starting from 14th March excluding weekends. <BR> Is there any function exists. I was trying to use DateAdd("w",7,now) it should give me 27th March 2001 as VBScript documentation says that , but it does not work. So what is the difference between DateAdd("w",7,now) n DateAdd("d",7,now) both gives same ans.<BR> can any one help me to fix my problem

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## Read the docs more carefully...

In the VBScript docs for DateAdd, the REMARKS say (in part):<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; To add days to date, you can use Day of Year <BR>&nbsp; &nbsp; &nbsp; &nbsp; ("y"), Day ("d"), or Weekday ("w").<BR><BR>In other words, "d" and "w" and "y" all mean the same thing and produce the same result.<BR><BR>To add *WEEKS* to a date, you must use "ww", *not* "w".<BR><BR>The other trick you could use:<BR><BR>futureDate = DateAdd( "d", 7 * (numberOfDays/5), startDate )<BR><BR>See it? You divide the number of work days by 5 to get the number of work weeks and then multiply by 7 to get the number of total days.<BR><BR>

#### Posting Permissions

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