Convert date format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ifoel
    New Member
    • Jul 2007
    • 12

    #1

    Convert date format

    Hai All

    Im beginer in Mysql.
    I have field Date in MySql, with format "dd/mm/yyyy hh:mm:ss".
    How to Select it and format change like this "yyyy-mm-dd hh:mm:ss"?



    Date
    04/07/2007 21:23:37

    Change to

    Date
    2007-07-04 21:23:37

    how to works

    thanks in advance
  • fplesco
    New Member
    • Jul 2007
    • 82

    #2
    Originally posted by Ifoel
    Hai All

    Im beginer in Mysql.
    I have field Date in MySql, with format "dd/mm/yyyy hh:mm:ss".
    How to Select it and format change like this "yyyy-mm-dd hh:mm:ss"?



    Date
    04/07/2007 21:23:37

    Change to

    Date
    2007-07-04 21:23:37

    how to works

    thanks in advance
    Hi -

    If you are concerned on that format because you are using it in VB,
    you may just SELECT it as is in the table. What you are going to do is, when you transfer it into a variable, you use FORMAT function(see below)

    dtVar = format(theDate, "yyyy-mm-dd hh:mm:ss")

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      The important thing to remember is that it is just stored as a date. It is not stored in any particular format; it's just a number. Usually a number indicating the number of hundredths of a second since some particular date in history, or something equally silly. The point is, you just apply whatever format you want, once you pull it out of the database.

      Plus, of course, when you send a value to the SQL interpreter, it and you have to agree on the format used to represent the date. I believe the SQL standard is mm/dd/yyyy format for dates.

      Comment

      Working...