SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Aug 2005
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL date formatting function

    Anyone know how to format a date with MySQL? I tried

    DATE_FORMAT(t.post_date, '%W %D %Y') AS date,

    In my SQL but it doesn't seem to be working

    Thanks
    Steven

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to put your date in yyyy-mm-dd format into mysql and use date_format to display it is that what you are doing?

  3. #3
    SitePoint Addict
    Join Date
    Aug 2005
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Dave,
    the column post_date uses the MySQL 'date' type it is aliased as t.post_date. Can I not format this with date_format?


    Thanks

  4. #4
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should be able to output it with date_format, you can't actually change the values in the database if that is what you mean.

    Can you show some sample rows from your table and also do a
    Code:
    show create table tablename
    and paste that here as well?


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
  •