Friday, April 24, 2015

Displaying overdue PO's

Why would you want to make non-sargable WHERE condition? 

Why not

DueDate < dateadd(day, -3, CURRENT_TIMESTAMP)


For every expert, there is an equal and opposite expert. - Becker's Law


My blog


My TechNet articles


Good point, thanks for the correction. A sargable query would be better. 

Note, however, that depending on what the OP means by "past that date over 3 days" the CURRENT_TIMESTAME needs to be cast as a date.  If the duedate column contains 2015-04-24 00:00:00.000 and the OP only wants that row to be returned if the current date is 2015-04-28 or later, then the above where condition needs to be

DueDate < dateadd(day, -3, CAST(CURRENT_TIMESTAMP as date))
Tom

No comments:

Post a Comment