> 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"....
I don't think you want DAYOFMONTH. Otherwise if today is July 24th, then a date column with June 24th, or any 24th, will come up as Today. Something like this will work, though... SELECT IF(TO_DAYS(CURDATE()) = TO_DAYS(date_column),'Today',IF(TO_DAYS(CURDATE())-1 = TO_DAYS(date_column),'Yesterday',date_column)) FROM your_table; Hope that helps... ---John Holmes... > Julio Nobrega > Pode acessar: > http://www.inerciasensorial.com.br > > > "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 > 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 > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php