[dba-SQLServer]Why Year 2001?

Djabarov, Robert Robert.Djabarov at usaa.com
Wed Sep 24 11:17:08 CDT 2003


This part:

dateadd(mm,-1-datepart(day,getdate()),getdate())

The result is -25 months

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of
Nicholson, Karen
Sent: Wednesday, September 24, 2003 11:37 AM
To: Dba-Sqlserver (E-mail)
Subject: [dba-SQLServer]Why Year 2001?


What part of this is telling it to extract the year 2001 instead of
2003?

select DATEADD(mm,
DATEDIFF(mm,0,dateadd(mm,-1-datepart(day,getdate()),getdate())),0)
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com



More information about the dba-SQLServer mailing list