[SOLVED] MySQL dates - checking less than more than a date i
Moderator: General Moderators
MySQL dates - checking less than more than a date in PHP?
Dear All,
I have a date stored in a MySQL table in standard MySQL 'date' format.
I also have a PHP string stored in DD/MM/YYYY format. Is there any way I can check whether this date is 'more' or 'less' than the date stored in the MySQL table? Or for example how many days away it is from this date?
Many thanks,
Mark
I have a date stored in a MySQL table in standard MySQL 'date' format.
I also have a PHP string stored in DD/MM/YYYY format. Is there any way I can check whether this date is 'more' or 'less' than the date stored in the MySQL table? Or for example how many days away it is from this date?
Many thanks,
Mark
yeah, easy, just use the less than/more than comparison
Mark
Code: Select all
SELECT * FROM some_table WHERE old_date > new_dateBech100,
Thanks for your suggestion. Rather than select rows in a table via a MySQL query, I need to make a comparative 'IF' statement - so I need the equivalent of
Thanks for your suggestion. Rather than select rows in a table via a MySQL query, I need to make a comparative 'IF' statement - so I need the equivalent of
Code: Select all
if ( $thisdate > $thatdate )
{
/* execute code */
}- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
^then
Code: Select all
SELECT UNIX_TIMESTAMP( `date` ) `date` FROM `table`Hi feyd,
I've tried this for the date cell 'CustomerViewFrom':
I get this output from $row['CustomerViewFrom']...
Which is the same as the query.
Many thanks
Mark
I've tried this for the date cell 'CustomerViewFrom':
Code: Select all
SELECT UNIX_TIME_STAMP('CustomerViewFrom') CustomerViewFrom FROM CustomersCode: Select all
SELECT UNIX_TIME_STAMP('CustomerViewFrom') CustomerViewFrom FROM CustomersMany thanks
Mark
Sorry my mistake - I asked my error output to display the query, not the error. It's generating the following error:
Cheers
Mark
Code: Select all
Error performing MySQL query - You have an error in your SQL syntax near '('CustomerViewFrom') CustomerViewFrom FROM Customers' at line 1Mark