0

How do I obtain the previous working date in a where clause

without doing the following and changing this manually

WHERE date = GETDATE()-1

The date column is datetime but I just need the date too.

Thom A
  • 88,727
  • 11
  • 45
  • 75
  • To get the "today" value in SQL: Select convert(date, GETDATE()) --e.g. 2022-11-15 (today) To get "yesterday": Select DATEADD(day, -1, convert(date, GETDATE())) --e.g. 2022-11-14 (yesterday) To get "today minus X days": change the -1 into -X. So for all yesterday's workday rows, you can: select * from tablename where date >= DATEADD(day, -1, convert(date, GETDATE())) and date < convert(date, GETDATE()) – Gaurav Chaudhary Nov 15 '22 at 13:00

0 Answers0