Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
1.40/5 (3 votes)
See more:
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
Updated 18-Sep-12 4:25am
v2
Comments
[no name] 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
cm_Aryan 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

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
 
Share this answer
 
v2
Comments
cm_Aryan 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

cm_Aryan 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900