Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retreive Yesterday's date

Status
Not open for further replies.

aajaydee

Technical User
Oct 16, 2005
39
US
How to retreive yesterday's date
I have to build a report which gets every day data for yesterday date
I tried with datepart("d", getdate()-1) and it's not working
Any help will be greate


 
Select Convert(varchar(10), GetDate() - 1, 121)


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
where DateColumn >=DATEADD(dd, DATEDIFF(dd, 0, GETDATE())+0, -1)
and DateColumn < DATEADD(dd, DATEDIFF(dd, 0, GETDATE())+0, 0)

to test

SELECT DATEADD(dd, DATEDIFF(dd, 0, GETDATE())+0, -1), DATEADD(dd, DATEDIFF(dd, 0, GETDATE())+0, 0)

Denis The SQL Menace
SQL blog:
Personal Blog:
 
Try DateAdd(d,-1,GetDate())

If you need Date only with no time, try
DateAdd(d,-1,dateadd(dd, datediff(dd,0,GetDate()),0))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top