[thelist] mySQL DATE_FORMAT question
Tanner Burson
tanner at younet.okstate.edu
Tue Jul 29 11:54:29 CDT 2003
*This message was transferred with a trial version of CommuniGate(tm) Pro*
Without knowing the format returned by DATE_FORMAT I would guess that
this should work:
SELECT
articleTitle,
articleID,
articleBlurb,
DATE_FORMAT('dateCreated', '%b %D %Y')
FROM
article
ORDER BY dateCreated DESC
LIMIT 3
I personally would just use timestamps then do the conversion to string
dates in whatever language you're using.
Tom Dell'Aringa wrote:
>*This message was transferred with a trial version of CommuniGate(tm) Pro*
>hello,
>
>I'm trying to format my date using the DATE_FORMAT function of mySQL.
>Here is my query:
>
>SELECT
> articleTitle,
> articleID,
> articleBlurb,
> DATE_FORMAT('dateCreated', '%b %D %Y')
>FROM
> article
>LIMIT 3
>
>'dateCreated' in my date field in the article table. I tried with and
>without quotes, both times getting the "Undefined index: dateCreated"
>error. All the docs say is:
>
>DATE_FORMAT(date,format)
>
>So I'm not sure what I am doing wrong. Would I be better off doing
>this in PHP instead?
>
>Also, related question - instead of LIMIT 3, I'd like to get the 3
>LATEST articles. I know that the first 3 won't necessarily be that.
>How can I select the latest 3 by date?
>
>TIA
>
>Tom
>
>=====
>http://www.pixelmech.com/ :: Web Development Services
>http://www.DMXzone.com/ :: Premium Content Author / JavaScript / Every Friday!
>http://www.maccaws.com/ :: Group Leader
>[Making A Commercial Case for Adopting Web Standards]
>
>"That's not art, that's just annoying." -- Squidward
>
>
More information about the thelist
mailing list