Friday, February 10, 2012

calculating a date difference...

Hi all...
Is there a function to calculate the number of months between 2 different
dates'
Example: @.varNumberOfMonths = DATEDIFF(month,'08/01/05','07/01,05' )
Thanks in advance for any help...You have a misplaced comma. Try this:
DATEDIFF(month,'08/01/05','07/01/05' )
"certolnut" <whitney_neal@.hotmail.com> wrote in message
news:e6CKawaqFHA.528@.TK2MSFTNGP09.phx.gbl...
> Hi all...
> Is there a function to calculate the number of months between 2 different
> dates'
> Example: @.varNumberOfMonths = DATEDIFF(month,'08/01/05','07/01,05' )
> Thanks in advance for any help...
>|||Did you try it?
DECLARE @.NumberOfMonths SMALLINT
-- we know it's a VAR because @., no var prefix necessary
SET @.NumberOfMonths = DATEDIFF(MONTH, '20050701', '20050801')
-- do not use mm/dd/yy format
PRINT @.NumberOfMonths
"certolnut" <whitney_neal@.hotmail.com> wrote in message
news:e6CKawaqFHA.528@.TK2MSFTNGP09.phx.gbl...
> Hi all...
> Is there a function to calculate the number of months between 2 different
> dates'
> Example: @.varNumberOfMonths = DATEDIFF(month,'08/01/05','07/01,05' )
> Thanks in advance for any help...
>

No comments:

Post a Comment