I'm writing a program that creates simple SQL based on Relative dates instead of real dates. So a user can pick an operator (<, >, =) and then choose a relative date:
Yesterday
Today
Tomorrow
ThisWeek
LastWeek
ThisMonth
LastMonth
ThisYear
LastYear
and the code would spit out something like this:
Does anyone know I can calculate the relative dates? for instance, if they pick Tomorrow, then how would I use getdate() to make it tomorrow? and so on for the rest of the relative dates?
Thanks in advance!
Yesterday
Today
Tomorrow
ThisWeek
LastWeek
ThisMonth
LastMonth
ThisYear
LastYear
and the code would spit out something like this:
Code:
SELECT i.DateCreated
FROM Items i
WHERE 1=1
AND i.DateCreated < getdate()
Does anyone know I can calculate the relative dates? for instance, if they pick Tomorrow, then how would I use getdate() to make it tomorrow? and so on for the rest of the relative dates?
Thanks in advance!