I can NOT make DATE_FORMAT work...any ideas?
Hello all,
In reviewing David Powers' fantastic book, 'PHP Solutions', I decided to do some work with dates in a database.
The table where the dates are stored is called cal_dates and is DATE type.
All the dates are stored as yyyy-mm-dd
When I write my query and add DATE_FORMAT, the page bombs no matter what I try.
As in:
SELECT *
DATE_FORMAT(cal_dates, '%c/%e/%Y') AS cal_dates
FROM cal_data
and I get a white screen.
So, I figured perhaps I should change the alias (the example in Pwers' book on page 390 does not use a different alias, but after struggling with this for almost 2 days, I am now trying anything):
SELECT *
DATE_FORMAT(cal_dates, '%c/%e/%Y') AS cdate
FROM cal_data
and I get another white screen.
Originally, my query was designed with a WHERE clause because I am selecting data from one table based on an a variable, but I read somewhere that DATE_FORMAT should not be used with WHERE...which is funny, since the two examples shown above with WHERE omitted still bomb.
The original query:
SELECT *
FROM cal_data
WHERE cal_data.page_ym = '$dateRef%'
works PERFECTLY. It pulls all information in the table relevant to the $dateRef variable.
The reason I wanted to use DATE_FORMAT is because I wanted to take the dates in my table from yyyy-mm-dd and display them in a different format.
But to no avail. Any thoughts or musings would be appreciated. I'm stonewalled.
Thank you all!
Sincerely,
wordman
