Friday, February 17, 2012

Datediff

Hello
What's the easiest way to get the number of months between two values like
this?
Present date 200505 (YYYYMM) and 199905 (YYYYMM)
Steve
Thank youAdd '01'
SELECT DATEDIFF
(
MONTH,
'199905'+'01',
'200505'+'01'
)
"Steve Read" <SteveRead@.discussions.microsoft.com> wrote in message
news:0B2957AF-9136-4750-87D8-A08E4644FB31@.microsoft.com...
> Hello
> What's the easiest way to get the number of months between two values like
> this?
> Present date 200505 (YYYYMM) and 199905 (YYYYMM)
> Steve
> Thank you|||Thank you very much Aaron, works nicely.
"Aaron Bertrand [SQL Server MVP]" wrote:

> Add '01'
> SELECT DATEDIFF
> (
> MONTH,
> '199905'+'01',
> '200505'+'01'
> )
>
>
> "Steve Read" <SteveRead@.discussions.microsoft.com> wrote in message
> news:0B2957AF-9136-4750-87D8-A08E4644FB31@.microsoft.com...
>
>

No comments:

Post a Comment