PDA

View Full Version : mySQL date_format howto?


Cale
09-27-2006, 01:01 AM
I have the following piece of code to format the date from my Query.
SELECT date_format(my_date, '%Y%c/%d') AS the_date
but the %c is for the monthy removes the 0 (zero) on months 01-09. is there a format that will retain the zero or do i need to figure a way to get that zero back in the variable.

The Reason is because I need to compair $the_date with $new_date = date ('Y/m/d')
the select date_format results is 2006/9/20 and the date function results is 2006/09/20
and the are not the same.

Thanks
-C

Brandoe85
09-27-2006, 01:38 AM
Yep, use %m

Ref:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

Good luck;

Cale
09-27-2006, 03:00 AM
Brandoe85 to my rescue again, Thanks!! Not sure how I missed the %m but that worked perfectly.
Thanks.