Reputation: 3761
I have the following where clause in my query:
(DATEPART(hh,[AuditInsertTimestamp]) >= 17
OR DATEPART(hh,[AuditInsertTimestamp]) <= 6)
So Audit Insert Timestamp is greater or equal to 5PM and Audit Insert Timestamp is less than or equal to 6AM. Where really what I want is Audit Insert Timestamp is less than or equal to 5:30AM. I was thinking about adding:
--AND DATEPART(mi,[AuditInsertTimestamp]) < 30)
But that would only give me times with minutes below 30 correct? What would be the best way to get <= 5:30AM?
Upvotes: 1
Views: 78
Reputation: 65157
(
DATEPART(hh,[AuditInsertTimestamp]) >= 17
OR DATEPART(hh,[AuditInsertTimestamp]) < 5
OR (DATEPART(hh,[AuditInsertTimestamp]) = 5
AND
DATEPART(minute,[AuditInsertTimestamp]) <= 30)
)
Upvotes: 3