I am not sure it works, since isn't tested, but here we go. It's pure
Mysql, and it would be probaly easier, faster, and more readable to do with
PHP mixed. But where's the fun of it? ;-)
date_field is the name of your date column.
$sql = "SELECT IF(DAYOFMONTH(date_field) = DAYOFMONTH(CURRENT_DATE),
'Today', IF (date_field = DATE_SUB(date_field, INTERVAL 1 DAYS),
'Yesterday', date_field)) FROM table"....
If the date isn't today or yesterday, you will get the date_field contents.
"Alexander Ross" <[EMAIL PROTECTED]> escreveu na mensagem
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I have a column in one of my mysql tables which holds the date & time that
> the record was inserted. When I run a query later on I want to display
> date, but if the date is today or yesterday I want to display "today" or
> "yesterday" instead .. how do i compare to stored date with todays date?
> todays date -1? Thanks
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php