0

I’m trying to patch a routine and I finally found the problem. I am given the following string:

$query = "SELECT title, DATE_FORMAT(event_date, '%Y-%c-%e') AS event_date FROM $dbTable WHERE event_date LIKE '$year-$month%'";

In the month variable at the end, for the months January through September I am returned 1 digit. So without disturbing the rest of the code, I would like to turn the month string into two digits but so far I have not been able to do that with the DATE_FORMAT function.
So in January, I am looking for the end result to look like:

$query = "SELECT title, DATE_FORMAT(event_date, '%Y-%c-%e') AS event_date FROM event WHERE event_date LIKE '2010-01%'";

I hope that makes sense.
Help would be appreciated.
WBR

1
Contributor
1
Reply
8
Views
7 Years
Discussion Span
Last Post by rouse
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.