Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Date

Author  Topic 

ann
Posting Yak Master

220 Posts

Posted - 2007-04-10 : 10:26:27
How do I find if a field is less than or equal to system date,
where PCDate <= systemdate (today or in the past)? I was using datediff but that doesn't seem right?
Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-10 : 10:29:09
WHERE PcDate <= CURRENT_TIMESTAMP
or
WHERE PcDate <= GETDATE()

These two will get you all records until this very millisecond.
If you want yesterdays and earlier records only, try this

WHERE PcDate < DATEADD(DAY, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP), 0)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

ann
Posting Yak Master

220 Posts

Posted - 2007-04-10 : 10:30:12
Thank you for such a quick response :)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-11 : 08:56:52
http://sql-server-performance.com/fk_datetime.asp for more informations on dates

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -