Reputation: 21
I have a requirement where if
getdate()
returns time between midnight 12 to 2 AM, I should consider Date of previous day. How to frame this in a select query ?
Upvotes: 1
Views: 313
Reputation: 1269973
The simplest method is to subtract two hours from the date and do the comparison. For instance:
where col_date < convert(date, dateadd(hour, -2, getdate()))
Upvotes: 1