Page 1 of 1

get all records added in last 3 days

Posted: Wed Nov 01, 2006 1:44 pm
by amir
ive got a slight issue where im facing to display all records that were added in the last 3 days from the current date.

our table contains a field called joined and i store a date value in it like:

Code: Select all

$joined = date('F j, Y, g:i a');
so what date functions would i use to display all records in the last 3 days?

Posted: Wed Nov 01, 2006 1:51 pm
by hawleyjr
Take a look at the mysql date and time functions:

http://dev.mysql.com/doc/refman/4.1/en/ ... tions.html

The very first example should help you

Code: Select all

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

Posted: Wed Nov 01, 2006 1:53 pm
by RobertGonzalez
Bear in mind that the newer (and more useful) date functions in MySQL are only available as of 4.1 (in some cases, 4.0, but almost none of the good ones are in 3.23).

Posted: Wed Nov 01, 2006 2:05 pm
by amir
Thanks guys!

I got it working...