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 statement

Author  Topic 

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2012-03-09 : 11:06:33
Hello everyone

I am after a date statement

Todays date -1 day and then -1 one second.

Regards Rob

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-09 : 11:21:40
DATEADD(dd,-1,DATEADD(ss,-1,GETDATE()))

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2012-03-09 : 11:27:13
what about from today (getdate()) and go back to '07-Mar-2012 23:59:59
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-09 : 11:33:54
apply similar logic itself based on DATEADD

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2012-03-09 : 11:44:47
got it

select dateadd (ss, -1,datediff(dd, +1,getdate()))
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-09 : 11:48:20
select dateadd (ss, -1,dateadd(dd, -2,getdate()))

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -