Jump to content

Change today's date to "today"


AdRock

Recommended Posts

There might be better ways but something like this would work:

 

SELECT IF(date_field = CURDATE(), 'today', IF(date_field = DATE_SUB(CURDATE(), INTERVAL 24 HOUR), 'yesterday', date_field)) FROM table_name

 

Of course it would then be easier to use MySQL's DATE_FORMAT function on the date field rather than doing it in PHP, to save checking for a valid date.

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.