I need to create a SSIS package that will go through the records in one table(T1)
older than 3 months (based on ALERT_TIMESTAMP
) a
Try this
select * from `table` where `yourfield` >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH)
For days, year see below for example.
DATE_SUB(CURDATE(), INTERVAL 15 DAY) /*For getting record specific days*/
DATE_SUB(CURDATE(), INTERVAL 1 YEAR) /*for getting records specific years*/
BETWEEN DATE_SUB( CURDATE( ) ,INTERVAL 6 MONTH ) AND DATE_SUB( CURDATE() ,INTERVAL 3 MONTH )
/* For Getting records between last 6 month to last 3 month
What you posted is not MySQL. Assuming you are using MS SQL Server, you should use the ABS()
function.
SELECT * FROM T1
WHERE ABS(DATEDIFF([month], ALERT_TIMESTAMP, GETDATE())) > 3