Forum Moderators: coopster

Message Too Old, No Replies

Date manipulation in mysql

         

gggmicrosystems

6:36 pm on Aug 11, 2005 (gmt 0)



hi. got a noob question...

how can I display all records for the past 3 months from db?

im only using the type date.

I just need the sql syntax...

thanx.. any help would be appreciated. ",

sned

6:48 pm on Aug 11, 2005 (gmt 0)

10+ Year Member



From the mysql manual date and time [dev.mysql.com] functions:

SELECT something FROM tbl_name WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= date_col;

I believe you can use months in the interval, so in your case, it would be 'INTERVAL 3 MONTH'

-sned