Results 1 to 4 of 4

Thread: Date Format

  1. #1
    Join Date
    Dec 2005
    Posts
    4

    Unanswered: Date Format

    Hello,

    Im trying to create a mysql table which will have some attributes set as DATE. However i want to change the format of the date from yyyy-mm-dd (which is the default) to dd-mm-yyyy.

    The create code i am using is below and i have tried a number of differnent ways to alter the date, but nothing seems to work!!

    CREATE TABLE T_BALANCE (T_LAST_DATE DATE DEFAULT 'MM-DD-YYYY');


    I have searched the web abit but cant find any way of doing it... can anyone help??

    Cheers,

    Rich

  2. #2
    Join Date
    Dec 2005
    Location
    Arnhem, Gld, NL
    Posts
    21
    i also struggled with this and i now format the dates in my code so they fit in the format mysql describs.
    When selecting dates, and displaying them, i format them again to show them in the format i want...

    i do not know a way to change the format in wich mysql stores it's date-values

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    In short you can't. Like all database engines my sql stores dates in its own sweet way. You can however set a format in the query or in the user interface (screens or reports)

    for use in the queery have a look at the mysql date functions such as DATE_FORMAT(<mycolumn>,"mask")
    - you will probably want mask to be '%m %d %Y'

    as to formatting in your user interface then refer to that applications date functions. There is a lot to be said to leaving the formatting to the user interface rather than in a query.
    HTH
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Dec 2005
    Posts
    4
    Hi,

    Cheers for the respone, frustraiting that u cant change it in the db, never mind i created a php function to convert it all.

    Thanks for the help!!

    Rich

Posting Permissions

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