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)
 One Day Minus the Current Date

Author  Topic 

Olad

11 Posts

Posted - 2008-11-08 : 03:01:44
I wanted to daily run a query that has yesterday's date. In other words, I want to have one day less than the current date which is in the yyyymmdd format.

I got as far as writing DATEADD(day, -1, GETDATE()) but this gives the date as well as the time. How can I remove the time and end up having the date in the yyyymmdd format.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-08 : 03:57:14
DATEADD(day,DATEDIFF(day,0,GETDATE())-1,0)
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-08 : 11:32:59
DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), -1)



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Olad

11 Posts

Posted - 2008-11-10 : 23:32:30
Both are perfect statements...Peso and Visakh.....I thank you. I appreciate your help.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-11 : 00:20:28
cheers
Go to Top of Page
   

- Advertisement -