|
Posted by Rik on 08/07/06 12:54
mpar612@gmail.com wrote:
> Hello everyone,
>
> I am having some difficulty with the date_format function in MySQL. I
> have an 'add_date' column in my database as a timestamp type. This
> automatically adds the current date and time when a user submits a
> form. I am using PHP and trying to format the date.
>
> I am using the following query:
>
> SELECT isbn, artist_name, album_title, release_date,
> date_format(\'add_date\', \'%M %d %Y\'), description, price FROM
> lounge
>
> When I run this query my date returns null.
That's correct, the string 'add_date' isn't a date. Use backticks (` instead
of ') around fieldnames, or they'll be interpreted as strings. In this case
the backticks are probably not even necessary:
"SELECT isbn, artist_name, album_title, release_date, date_format(add_date,
'%M %d %Y') as 'add_date', description, price FROM lounge"
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|