GETDATE()

Now assume we’d like data from yesterday, and not from today:

SELECT *

FROM database_table

WHERE date = GETDATE() - 1

  • Now, the GETDATE() function will return the previous day’s date instead of today’s date.

  • To get the date from a week ago, use GETDATE()-7 instead.