Jump to content

Comparing a given datetime to this time x months ago


tendrousbeastie

Recommended Posts

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.