Here is the Query to fetch Last 'N' Year Data or Last 'N' Months data or Last 'N' Day data.
Trick is using DATEADD(YEAR,-2,GETDATE()).
This Query will fetch Last 2 year record. Change Year to Months and Number, to get last 'N' Month data and so on.
Trick is using DATEADD(YEAR,-2,GETDATE()).
This Query will fetch Last 2 year record. Change Year to Months and Number, to get last 'N' Month data and so on.
SELECT * FROM TABLE_Name WHERE DATE_COLUMN > DATEADD(YEAR, - 2, GETDATE())
Comments
Post a Comment