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

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -