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

DATEADD to add a 'REAL' Month not 30 days

Status
Not open for further replies.

PCStorm

MIS
May 29, 2002
31
US
DATEADD(MONTH,1,'6/30/99') returns 7/30/99 I want it to return 7/31/99. If the date is 6/15/99 I would want it to return 7/15/99 (which it does).

Please, any ideas of what to do here?
 
The design behaivor of the DATEADD is to add up to the number of days in the current month without exceeding the actual next month. IE you add 31 days to Jan 31 should you skip February all together? According to Microsoft the answer is no. What this means is if you start at Jan 31 and add 12 individual months you come to Dec 28.

If you want to alter this procedure you'll have to create your own function.
 
If you want the last day of the month, you can go to the first of the next month and subtract 1 day.

dateadd(d,-1,(DATEADD(mm,1,'7/1/99')) )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top