Re: date
| From: | Julio Nobrega | Date: | Wed, 24 Jul 2002 22:47:42 +0000 |
| Subject: | Re: date | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-109371@lists.php.net to get a copy of this message | ||
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.
--
Julio Nobrega
Pode acessar:
http://www.inerciasensorial.com.br
"Alexander Ross" <alexross@bleen.net> escreveu na mensagem
news:20020724203928.45708.qmail@pb1.pair.com...
> 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
the
> 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
>
>