Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateAdd for weekdays not working

Status
Not open for further replies.

Sinbad

Programmer
Nov 27, 2000
36
US
I am trying to use the DateAdd function to add weekdays to a variable I am using but it only returns actual days not weekdays.
Here is the code I am using:
<cfset ticketApproveDate = DateAdd(&quot;w&quot;,3,#Now()#)>

Anyone else have this problem or know why this is happening?

Thanks Allan Jagos
Web Developer
Robinson & Cole LLP
 
Odd that all this datepart stuff came up on the same day.

The docs for DateAdd() state &quot;The datepart specifiers &quot;y,&quot; &quot;d,&quot; and &quot;w&quot; perform the same function add a number of days to a date.&quot; ... so I would have to guess that &quot;w&quot; isn't really supported by DateAdd. It's just there so things don't break if you happen to exchange the datepart portion with other date functions (like DatePart() or DateDiff()). It will always just add actual days. Hope it helps,
-Carl
 
if by &quot;weekdays&quot; you mean monday through friday only, then you may be getting different answers than you expect

today is wednesday -- what is 3 weekdays from today?

i say saturday, you say monday, we all scream for ice cream...


rudy
 
Looks like the &quot;w&quot; does not give you just weekdays but rather all days. Thanks for your responses.
I used the following code to take into account weekends:
<cfif DayOfWeek(#Now()#) LT 4>
<cfset ApproveDays = 2>
<cfset LastChanceDays = 3>
<cfelseif DayOfWeek(#Now()#) IS 4>
<cfset ApproveDays = 2>
<cfset LastChanceDays = 5>
<cfelseif DayOfWeek(#Now()#) GT 4>
<cfset ApproveDays = 4>
<cfset LastChanceDays = 5>
</cfif>
Allan Jagos
Web Developer
Robinson & Cole LLP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top