Re: Date calculation
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 08/03/04
- Previous message: Bob: "Date calculation"
- In reply to: Bob: "Date calculation"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 03 Aug 2004 21:59:59 +0200
On Tue, 3 Aug 2004 10:37:13 -0700, Bob wrote:
>Im relatively new with sql and im having a problem
>creating a criteria based on todays date less 150 days.
>
>I tried to use the following...
> < GetDate () -150 however it will not let me use this.
>
>I know that there must be away to do this, but I need
>help.. Thank you in advance
Hi Bob,
Try it with DATEADD(day, -150, getdate()).
If you remove the space between getdate and (), your code would work as
well, but I recommend using DATEADD anyway - just subtracting 150 relies
on the internal storage of datetime values; this is not guaranteed to
remain unchanged between SQL Server versions.
Also remember that getdate() gives current date *AND* time. Not a problem
for "smaller than" comparissons, but if you ever have to match on "equal"
date, you'll have to use some extra tricks to get rid of the time portion.
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Previous message: Bob: "Date calculation"
- In reply to: Bob: "Date calculation"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|