How do I go back to last April 4th (from today), minus 4 years, and return that date?
I could start by checking if today’s date is before or after April 4 this year and go from there, but I would be interested to see different approaches to this issue.
This will be part of a larger select statement, so a self-contained SELECT or a function would be the best solution.
Thanks!
I can’t find any neater way of doing this – I normally fall back on my tried and true
DATEADD/DATEDIFFpair to do date calculations, but I can’t think of a way to take account of how far through the year we are neatly – so we get aCASEexpression as well:For testing particular dates to check edges conditions:
If you just need 4th April of the year four years before the current year, then
will suffice.