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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dateadd Function: Months Not Working

Status
Not open for further replies.
Feb 9, 2009
77
US
Why is that when I do dateadd("m",-3,#6/30/2009#) the returning value is 3/30/09 not 3/31/09? I feel like this has not always been the case, is it a local setting? This is driving me nuts!
 
This result is correct.

The function is removeing 3 whole months so should return the same date 3 months ago.

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
From Crystal Help:

DateAdd ("m", 1, #1/31/1996#)

Returns the DateTime value for February 29, 1996. Notice that DateAdd will not return the invalid value February 31, 1996.

So using that logic wouldn't the return value be March 2nd because it is adding 31 days? What do you mean by "3 whole months?
 
If today is July 22nd what date was it 3 months ago ?

I would expect to see April 22nd wouldn't you, The help text above is simply stagign that the function will not return invalid dates i.e.

dateadd("m",-3,#7/31/2009#) will return 4/30/2009 because 4/31/2009 is not a valid date.

Gary Parker
MIS Data Analyst
Manchester, England
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top