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 9027643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:47:39+00:00 2026-06-16T06:47:39+00:00

I am Inserting this DateTime data ’12/21/2012 1:13:58 PM’ into my MySQL Database using

  • 0

I am Inserting this DateTime data '12/21/2012 1:13:58 PM' into my MySQL Database using this SQL string:

String Query = "INSERT INTO `restaurantdb`.`stocksdb` 
                  (`stock_ID`,`stock_dateUpdated`) 
                  VALUES ('@stockID' '@dateUpdated');

and I receive this error message:

Incorrect datetime value: '12/21/2012 1:13:58 PM' for column 'stock_dateUpdated' at row 1

So what is the right format/value for dateTime to input into a MySQL database?

  • 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-16T06:47:41+00:00Added an answer on June 16, 2026 at 6:47 am

    Q: What is the right format/value for DATETIME literal within a MySQL statement?

    A: In MySQL, the standard format for a DATETIME literal is:

     'YYYY-MM-DD HH:MI:SS'
    

    with the time component as a 24 hour clock (i.e., the hours digits provided as a value between 00 and 23).

    MySQL provides a builtin function STR_TO_DATE which can convert strings in various formats to DATE or DATETIME datatypes.

    So, as an alternative, you can also specify the value of a DATETIME with a call to that function, like this:

    STR_TO_DATE('12/21/2012 1:13:58 PM','%m/%d/%Y %h:%i:%s %p')
    

    So, you could have MySQL do the conversion for you in the INSERT statement, if your VALUES list looked like this:

    ... VALUES ('@stockID', STR_TO_DATE('@dateUpdated','%m/%d/%Y %h:%i:%s %p');
    

    (I notice you have a required comma missing between the two literals in your VALUES list.)


    MySQL does allow some latitude in the delimiters between the parts of the DATETIME literal, so they are not strictly required.

    MySQL 5.5 Reference Manual.

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

Sidebar

Related Questions

Pulling some data from MongoDB and inserting it into a MySQL database, using Python
I am having a problem inserting DATETIME into MySQL using PHP. First, I am
I have a problem with inserting data into SQLite database using QSqlTableModel. The table
I am facing the problem while inserting data this way. How to insert data
Keep getting this error after inserting a subdatasheet into a query and trying to
I am parsing a log and inserting it into either MySQL or SQLite using
I was using phpmyadmin to insert some dummy data into a table, and noticed
I'm now inserting a date/time data into my date/time field in the database. I
I'm having trouble inserting image data into my database. I have a table called
I'm inserting a DateTime into MsSQL using the GetUTCDate() function provided by MsSQL. I

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.