SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Date_format()

  1. #1
    SitePoint Zealot zook's Avatar
    Join Date
    May 2001
    Location
    Houston, tx
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Date_format()

    I'm having trouble getting the results I'm looking for here. What I'm doing is pulling info about articles from a database, including the date it was written. The date is stored in the database as yyyy-mm-dd. I need to format the date into somthing like Oct-08-2001...

    Here the code I came up with, but it doesn't work.

    PHP Code:
    $result mysql_query("SELECT id, title, intro, date_format(date,%b-%d-%Y) AS nicedate FROM articles WHERE CATID=$catid AND SUBCATID=$subcatid");
    while ( 
    $row mysql_fetch_array($result) ) { 
    $id $row["id"];
    $title $row["title"];
    $intro $row["intro"];
    $date $row["nicedate"];
    echo(
    "<p><a href=\"/article/$id/1\"><strong>$title</strong></a><br><font class=\"small\">$intro<br><br>$date</font>");

    Does anybody know why this isn't working?

  2. #2
    SitePoint Addict rwar's Avatar
    Join Date
    Sep 2001
    Location
    PF / RS / BR
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you look the manual? I thought I have read this in some place (I think the manual...)
    php? mysql? apache? That's it.

  3. #3
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    put quotes around the formatting part. e.g. - DATE_FORMAT(date, '%b-%d-%Y')
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  4. #4
    SitePoint Zealot zook's Avatar
    Join Date
    May 2001
    Location
    Houston, tx
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    put quotes around the formatting part. e.g. - DATE_FORMAT(date, '%b-%d-%Y')
    and that that did! thanks doc


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •