Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8756991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:12:05+00:00 2026-06-13T14:12:05+00:00

I am redesigning a database that currently imports ISO 8601 dates in the format

  • 0

I am redesigning a database that currently imports ISO 8601 dates in the format of 2012-10-27T07:30:38+00:00 into a varchar field. The current database is hosted on a MySQL 5.5 server.

In searching through documentation and various SO posts, I have not found a definitive answer on what datatype I should use in MySQL for this purpose. The closest post is: MySQL insert to DATETIME: is it safe to use ISO::8601 format? where it provides a work around of sorts, however this is not a desirable option.

The MySQL documentation (http://dev.mysql.com/doc/refman/5.5/en/date-and-time-types.html) does not say, and the only reference I can find on official documentation is located on page: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html

which states “The possible values for the first and second arguments result in several possible format strings (for the specifiers used, see the table in the DATE_FORMAT() function description). ISO format refers to ISO 9075, not ISO 8601.”

Now the PostgreSQL documentation specifically mentions ISO8601 ( http://www.postgresql.org/docs/9.2/static/datetime-keywords.html and http://www.postgresql.org/docs/9.2/static/datatype-datetime.html ) which leads me to my question:

Does MySQL correctly support ISO 8601, or should I consider a database with native support?

–Edit–

Attempting to insert the example time stamp above into a datetime column gives the following error:

10:55:55    insert into test(date1) values('2012-10-27T07:30:38+00:00') Error Code: 1292. Incorrect datetime value: '2012-10-27T07:30:38+00:00' for column 'date1' at row 1 0.047 sec
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:12:06+00:00Added an answer on June 13, 2026 at 2:12 pm

    Do not store date or timestamp values in a varchar column. You have no way of ensuring that a correct value is stored (no one prevents you from storing 2012-02-31 28:99:70 in there.

    If you don’t need the time part, use a date datatype (available in MySQL and PostgreSQL) if you do need the time use a timestamp (or datetime in MySQL) data type.

    The formatting of the values should be done in your frontend or if you absolutely have to do it in SQL using e.g. to_char() (or the equivalent in MySQL) when retrieving the values.

    Again: never store dates or timestamps in a varchar (just as you should never stored real numbers in a varchar column).

    Here is the MySQL overview for date/time datatypes: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-types.html

    Here is the PostgreSQL overview for date7time datatypes: http://www.postgresql.org/docs/current/static/datatype-datetime.html

    Edit

    If you are concerned about the literal format. Both DBMS support the standard ANSI Date and Timestamp literals:

    insert into some_table 
       (ts_column, date_column)
    values
       (timestamp '2012-10-27T07:30:38+00:00', DATE '2012-12-30');
    

    SQLFiddle for PostgreSQL: http://sqlfiddle.com/#!12/cdd39/1

    Note the keywords timestamp and date in front of the character literal.

    Edit 2

    It seems MySQL cannot insert such a value, although it can use that literal in a SELECT statement:

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been tasked with redesigning part of a ms-sql database structure which currently involves
I'm currently redesigning my website and have been looking into using JavaScript and jQuery.
I am redesigning a few databases into one encompassing database, and I have noticed
I'm currently redesigning a old application of mine. I'm unsure in which form to
For a current project, we're designing a client desktop application that parses text files
I am redesigning a .NET system that stores >1000 multipage .TIF images per day
I am reviewing / redesigning / refactoring a database and want to create a
I am playing around with Object Oriented Design/Database design by creating an application that
I'm redesigning a web site that has a bunch of tags in the content
I have a collection of entities that I generated from a database. One table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.