datetime question

  • Thread starter Thread starter Mike Painter
  • Start date Start date
M

Mike Painter

I want to find all events that occurred yesterday.
In Access this would be dateAdd( "d", -1, Date())

How is it expressed in a query in SQL?
Using GetDate() returns an error message.
 
Mike said:
I want to find all events that occurred yesterday.
In Access this would be dateAdd( "d", -1, Date())

How is it expressed in a query in SQL?
Using GetDate() returns an error message.

GetDate() should work.

For an adp:
Select * from Orders where Orderdate = Getdate()-1

Regards

Peter Russell
 
try this:
it is not much elegant but should work fine (at the end of
month / year too)

SELECT *
FROM orders
WHERE (DATEPART(year, orderdate) = DATEPART(year, getdate
() - 1)) AND (DATEPART(month, orderdate) = DATEPART(month,
getdate() - 1)) AND (DATEPART(day, orderdate) = DATEPART
(day, getdate() - 1))
 
Back
Top