I'm trying to select for all items where the createDt is in the last two weeks. I've tried this code but it doesn't work.
SELECT * FROM dbo.mytable
WHERE CreateDt > dateadd(d,-15,CreateDt)
Can someone tell me the correct way to do this?
WHERE CreateDt > dateadd(d,-15,CreateDt)
should be
WHERE CreateDt > dateadd(d,-15,getdate())
Presumably.
All NOT NULL
values of CreateDt
will meet your current condition as you are comparing the column with its own value minus 15 days - not 15 days previous to the current date and time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With