You are here: Re: date_format with MySQL and PHP « PHP SQL « IT news, forums, messages
Re: date_format with MySQL and PHP

Posted by mpar612 on 08/07/06 13:00

Rik wrote:
> 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

Excellent, works great now. Thank you!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация