SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 One Day Minus the Current Date
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Olad
Starting Member

United Kingdom
11 Posts

Posted - 11/08/2008 :  03:01:44  Show Profile  Click to see Olad's MSN Messenger address  Reply with Quote
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.

Edited by - Olad on 11/08/2008 03:04:00

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 11/08/2008 :  03:57:14  Show Profile  Reply with Quote
DATEADD(day,DATEDIFF(day,0,GETDATE())-1,0)
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30282 Posts

Posted - 11/08/2008 :  11:32:59  Show Profile  Visit SwePeso's Homepage  Reply with Quote
DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), -1)



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

Olad
Starting Member

United Kingdom
11 Posts

Posted - 11/10/2008 :  23:32:30  Show Profile  Click to see Olad's MSN Messenger address  Reply with Quote
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

India
52325 Posts

Posted - 11/11/2008 :  00:20:28  Show Profile  Reply with Quote
cheers
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000