Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2012
    Posts
    4

    Unanswered: How to deal with time format in mysql

    i have a time format that i want to insert into a mysql database.

    the format it

    4/3/2012 9:54:03 AM


    what type can i set the column to be for this format to work ?

  2. #2
    Join Date
    Mar 2012
    Posts
    12
    Quote Originally Posted by armasmike View Post
    i have a time format that i want to insert into a mysql database.

    the format it

    4/3/2012 9:54:03 AM

    what type can i set the column to be for this format to work ?
    You probably want the TIMESTAMP format. Do not let the fact that the dates are stored in ISO format YYYY-MM-DD disturb you or prevent you from selecting this format. When the date is retrieved from the database, your web (or other) application will reconvert it to the syntax for your local system.

    For more info, see MySQL :: MySQL 5.0 Reference Manual :: 10.3.1 The DATE, DATETIME, and TIMESTAMP Types

  3. #3
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Try the STR_TO_DATE function which converts the passed in string into a date time value based on the format of the input string.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

Posting Permissions

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