Forum Discussion
MrPatrick
Helper I
4 years agoRestricting data import by date - MySQL
I've got a database where all the tables go back to ~2013 but I'm only interested in the last 12 months. Currently I either import the whole lot and then filter it (which is incredibly slow and prone...
- 4 years ago
Why not make the start date dynamic on your query? In T-SQL it would be.
WHERE Event_Date >= DATEADD(MONTH,-12,CONVERT(DATE,GETDATE()))
v-yalanwu-msft
Community Support
4 years agoHi, MrPatrick ;
Please try it
select * from agent_log_backup where event_time >= (current_date - INTERVAL '12 months')
or
select * from agent_log_backup where event_time BETWEEN DATE_SUB( CURRENT_DATE, INTERVAL 12 MONTH ) AND CURRENT_DATE
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.