Page 1 of 1

[SOLVED]DATETIME conditional expressions.

Posted: Wed Jun 18, 2008 9:45 pm
by JellyFish
I have a table with a DATETIME field. I would like to select all fields in this table that is larger then the current time minus x seconds/minutes.

For example:

Code: Select all

 
$sql = "SELECT * FROM `table` WHERE `date` > (CURRENT_TIME - X_TIME)"; //Where X_TIME is a few seconds or minutes.
 
This will allow me to select all records that are only moments new.

Thank you for taking the time to read this post.

Re: DATETIME conditional expressions.

Posted: Wed Jun 18, 2008 10:08 pm
by JellyFish
Ok nevermind I figured it out.

Code: Select all

 
$sql = "SELECT * FROM `table` WHERE `date` > NOW() - INTERVAL 2 MINUTE";
 

Re: [SOLVED]DATETIME conditional expressions.

Posted: Wed Jun 18, 2008 10:43 pm
by califdon
When you have solved your problem, PLEASE return to your original post, edit it and add the word [SOLVED] to the Subject. I have done that for you, this time.