# question

## How to use DateDiff() with constant value as parameter?

In DateDiff(MM,0,GetDate()),does 0 indicate 01/01/1900? And in DateDiff(MM,-1,GetDate()),what do -1 stand for? does 0 and -1 are the only values ,used like this?

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

·
Yes. The zero reflects 1/1/1900 and the -1 reflects 12/31/1899, which is one day less than 1/1/1900. You can use any integer value as the start date. This, I believe, will reflect the number of days plus or minus from 1/1/1900 DECLARE @dte DATETIME = '1/1/1900' SELECT DATEDIFF(MM,0,GetDate()) -- 1388 SELECT DATEDIFF(MM,'1/1/1900',GETDATE()) -- 1388 SELECT DATEDIFF(MM,'12/1/1899',GetDate()) -- 1389 SELECT DATEDIFF(MM,32,GETDATE()) -- 1389 SELECT DATEDIFF(MM, @dte + 32,GETDATE()) -- 1387 SELECT @dte + 32 SELECT DATEDIFF(MM, '1900-02-02',GETDATE()) -- 1387 Hope that helps!
1 comment

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

·
Thanks JohnM
0 Likes 0 ·