Click here to Skip to main content
Rate this: bad
good
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 4:24am
Edited 18-Sep-12 4:25am
v2
Comments
Wes Aday at 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 at 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 at 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 at 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 at 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)



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