DateAdd() Insanity...

by Rich Rousseau 24. March 2006 04:30

 

Not all DateAdd()s are created equal.

Example:

VBScript
DateAdd("m", -1, CDate("01/01/2006"))
Expected Result: 12/01/2005
Actual Result: 12/01/2006 - WTF?

TSQL
DateAdd(m, -1, '20060101')
Expected Result: 12/01/2005
Actual Result: 12/01/2005

Moral of the story, not all functions behave like you expect them to. Test, test and retest.

Comments

3/24/2006 6:21:39 AM #

Marc

I knew VBScript blew monkeys.

Marc |

3/28/2006 4:41:02 AM #

Tony Real

You forgot to take into account that VBScript passes all of the information through a flux capacitor before giving you the result.

BTW....new tiki bar tv out! Smile

Tony Real |