Daniel
Daniel

Reputation: 35704

sql server time compare with offset

I've got a select query that returns a list of rows that have expired

  SELECT *
  FROM dbo.myTable
  WHERE  endDate < Convert(datetime, Convert(int, GetDate()))

how can I get it to use current day at 2AM instead of the current time I get from GetDate()

Upvotes: 1

Views: 247

Answers (1)

hkf
hkf

Reputation: 4520

To get the current day at 2AM:

convert(datetime,left(convert(varchar, getdate(), 121),10) + ' 02:00')

Upvotes: 1

Related Questions