tendrousbeastie Posted May 22, 2008 Share Posted May 22, 2008 Hi all, This may be a really obvious question, but I had a search and couldn't find an answer to it. Apologies if its answered elsewhere. I need to be able to run an SQL query on my MySQL DB that is essentially like the code below: SELECT fields FROM table WHERE date > now()-12months Hopefully my intention is obvious, - I want to return all result from the table where the column date contains a datetime of within the last months (or xx months preferably). Does anyone know the syntax or commands necessary to do this? Link to comment https://forums.phpfreaks.com/topic/106828-comparing-a-given-datetime-to-this-time-x-months-ago/ Share on other sites More sharing options...
Barand Posted May 22, 2008 Share Posted May 22, 2008 SELECT fields FROM table WHERE date > now() - INTERVAL 12 MONTH Link to comment https://forums.phpfreaks.com/topic/106828-comparing-a-given-datetime-to-this-time-x-months-ago/#findComment-547721 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.