Bernard Clement wrote:


Your select works fine within the month to the exception of the first day because curdate()-1 is treated as a numeric field (see curdate in http://www.mysql.com/doc/en/Date_and_time_functions.html)

The following seems to be what you want to do:
mysql> select date_format(curdate()- interval 1 day,'%Y%m%d');
+-------------------------------------------------+
| date_format(curdate()- interval 1 day,'%Y%m%d') |
+-------------------------------------------------+
| 20040229                                        |
+-------------------------------------------------+
1 row in set (0.00 sec)

or, if you want the '-'
mysql> select date_format(curdate()- interval 1 day,'%Y-%m-%d');
+---------------------------------------------------+
| date_format(curdate()- interval 1 day,'%Y-%m-%d') |
+---------------------------------------------------+
| 2004-02-29                                        |
+---------------------------------------------------+
1 row in set (0.00 sec)

You don't really need date_format for the latter, as you've specified the default format. You could just use:


mysql> select curdate() - interval 1 day;
+----------------------------+
| curdate() - interval 1 day |
+----------------------------+
| 2004-02-29                 |
+----------------------------+
1 row in set (0.00 sec)

Michael




-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to