Click here to Skip to main content
12,075,066 members (65,610 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP
Hi Everyone,

While i was working with classic ASP, I got a doubt that

What is the difference between

dateadd("d", 10, currentTime)
dateadd("w", 10, currentTime)

Both returns the same output. Both adds 10 days to the current datetime.
Is there any scenario where we can see the difference, so that i can use them exactly where they are required. I need the practical scenario not the theoretical definitions. If possible mail me [address removed]

Thanks in advance for your ideas.
Posted 18-Sep-12 5:24am
Edited 18-Sep-12 5:25am
v2
Comments
Wes Aday 18-Sep-12 10:40am
   
What is wrong with reading how to use the function? http://www.ezineasp.net/post/ASP-Vbscript-DateAdd-function-with-Date-Intervals.aspx
Member 9014578 18-Sep-12 11:14am
   
Hi Aday,

Thanks for you Comment. Actually i did that before itself.

My Problem is: both the parameters "w" and "d" when used with data function return the same output. What is the exact difference between the two parameters. Can you give an example where i can see the difference between them.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

The documentation here tells the difference:
HERE

d - is day of the month
w - is day of the week

Now for your purpose / dateadd () function - the interval parameter only indicates what unit of time you are adding to your initial date [10 days, months, years etc]
So for this function: d, w, and even y will be identical, because they are only telling the function "add x days"

For other functions there is a difference between the two
  Permalink  
v2
Comments
Member 9014578 18-Sep-12 11:13am
   
Thanks for that. Got clarity to some better extent.
As per your post w - is day of the week. Wqe know there are only 7 days a week. But when i specify 10 in place of w, i am getting the correct output, but as per the documentation reference given above It should be wrong because weekday must be between 1-7. Can you please clarify
Shaunak De 18-Sep-12 11:19am
   
You are a little confused on this. :)

Its very simple. Irrespective of w, d, or y, you are adding 10 "days". That is important in the adddate function. The interval is "day".

w will be used when you want to check if today is a monday or not, etc.

See the datepart method for use: http://msdn.microsoft.com/en-us/library/2dhha2f3.aspx

Member 9014578 18-Sep-12 11:24am
   
Got it. Thanks Dude....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160208.1 | Last Updated 18 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100