How do I retrieve data in SQL from a previous date in the pass 12 months in a WHERE CLAUSE using the date and time functions?
--ServiceDates in past 12 months WHERE YEAR(CONVERT(DATE, CLM_FROM_DT)) = 2016.
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
Both of these should work depending on what you need.
For any date range:
WHERE CLM_FROM_DT BETWEEN '20160331' AND '20170331'
If you are looking for 1 year back from current date:
If you are looking for 1 year back from specific date (2017-3-31) as per your comment:
WHERE CLM_FROM_DT>DATEADD(year,-1, '20170331')