Tuesday, February 14, 2012

Date

I have a SQL 2000 std server with SP4.
Is it possible to find excact date 24 months ago?
I mean if i use Select GETDATE() as Now i get todays date. But if i want to
find the date 24 months ago from todays date?
Select (GETDATE() - 24 months) as OldDate
any hint?
best regards
TrondYou can use Select DateAdd( mm, -24, GetDate() ). :-)
"Trond Hoiberg" <trond@.montanis.com> wrote in message
news:exU9YnFFGHA.3100@.tk2msftngp13.phx.gbl...
I have a SQL 2000 std server with SP4.
Is it possible to find excact date 24 months ago?
I mean if i use Select GETDATE() as Now i get todays date. But if i want to
find the date 24 months ago from todays date?
Select (GETDATE() - 24 months) as OldDate
any hint?
best regards
Trond|||Try: Select DateAdd(mm, -24, GetDate())
Trond Hoiberg wrote:
> I have a SQL 2000 std server with SP4.
> Is it possible to find excact date 24 months ago?
> I mean if i use Select GETDATE() as Now i get todays date. But if i want t
o
> find the date 24 months ago from todays date?
> Select (GETDATE() - 24 months) as OldDate
> any hint?
> best regards
> Trond
>|||SELECT DATEADD(month, DATEDIFF(month, '1900', GETDATE())-24,
'1900')+@.@.datefirst
"Trond Hoiberg" <trond@.montanis.com> wrote in message
news:exU9YnFFGHA.3100@.tk2msftngp13.phx.gbl...
>I have a SQL 2000 std server with SP4.
> Is it possible to find excact date 24 months ago?
> I mean if i use Select GETDATE() as Now i get todays date. But if i want
> to find the date 24 months ago from todays date?
> Select (GETDATE() - 24 months) as OldDate
> any hint?
> best regards
> Trond
>

No comments:

Post a Comment