sql - How do I find data from this day exactly one year ago? -
sql - How do I find data from this day exactly one year ago? -
right have:
year(epe_curremploymentdate) = year(dateadd(year, -1, sysdatetime()))
but giving me lastly year. want info today's date, 1 year ago.
it should be:
epe_curremploymentdate = dateadd(year, -1, getdate())
don't check year in clause.
edit:
simple: use
cast(epe_curremploymentdate date) = cast(dateadd(year, -1, getdate()) date)
that is, if using sql server 2008 , above.
sql sql-server datetime
Comments
Post a Comment