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
 General SQL Server Forums
 New to SQL Server Programming
 Date query (pulling system date)

Author  Topic 

Dan1980
Starting Member

9 Posts

Posted - 2013-11-01 : 08:08:51
Hello

Hoping someone can help.

I'm currently using the SQL to find records older than todays date in the SSD_SED field. I'm having to update the date manually each day. Is there a way I can automate this?

AND (SSD_SED < '2013-11-01')order by SSD_SED DESC

Regards

Dan

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2013-11-01 : 08:14:34
AND (SSD_SED < dateadd(day,datediff(day,0,getdate()),0))order by SSD_SED DESC

Madhivanan

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

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-11-01 : 08:14:56
[code]
select getdate()

or

select dateadd(day, datediff(day, 0, getdate()), 0)
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Dan1980
Starting Member

9 Posts

Posted - 2013-11-01 : 09:23:26
Thanks guys. Works great.
Go to Top of Page
   

- Advertisement -