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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:35:23+00:00 2026-05-15T09:35:23+00:00

There are some other questions where people have problems with timestamp being all zeros.

  • 0

There are some other questions where people have problems with timestamp being all zeros. I have checked them and this is not a duplicate.

I declare a table like this:

CREATE TABLE  `my_db`.`my_table` (
  `time_stamp` timestamp NOT NULL,
  `author` varchar() NOT NULL,
  `text` text NOT NULL,
  `md5` int(11) NOT NULL,
  PRIMARY KEY (`time_stamp`)
) ;

I also have a second table which will have a timestamp as primary key and they should have the same value.

Coding in Delphi, I use SELECT CURRENT_TIMESTAMP which returns something like '19/6/2010 4:56:17 AM' which I then use in an INSERT statement. The INSERT succeeds, but the timestamp is all zeros.

What am I doing wrong?

Here’s the INSERT code:

  sqlCommand := 'INSERT INTO my_db.my_table(time_stamp, author, text, md5) VALUES ("' 
                   + timestamp + 
                    '", "mawg", ' +
                    '"Hello, world"' +
                    0 +
                    '");';
  Result := DoSQlCommandWithNoResultSet(sqlCommand, AdoConnection);

Insertion will be extremely low rate, one entry every few weeks or maybe months, so I am happy with timestamp as primary key. I am keeping “versions” of things, so timestamp makes sense to me.

I am begging to think that this is an ADO problem, although I would expect ADO to just “pass through”. I don’t see any other solution. In a console, the output is “correct”, but when run through ADO in Delphi then it is wrong

Can I specify to MySQL how it ought to format its dates?

  • 1 1 Answer
  • 3 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-05-15T09:35:24+00:00Added an answer on May 15, 2026 at 9:35 am

    After reviewing the MySQL documentation, it appears that if your timestamp value is incorrectly formatted, it would normally cause the timestamp to be '0000-00-00 00:00:00'.
    In any case, you don’t need to specify a timestamp value—that’s the benefit of TIMESTAMP over DATETIME. And even if you did, you can simply set it to NOW() instead of running an unnecessary SELECT statement.

    Edit:

    Also, I know you said you thought this through, but have you considered daylight savings time? This could cause two records to have the same timestamp when the clock is set back during autumn.

    Edit 2:

    K, I don’t know why I didn’t catch this earlier, but that timestamp format you gave is incorrect. Try inserting a valid timestamp like '2010/06/19 4:56:17'. MySQL has pretty relaxed parsing of date & time values, but it always has to be year-month-date and hour-minute-seconds.

    Edit 3:

    Alright, there seems to be a little confusion over this, so I’m gonna post this quote from the MySQL 5.0 doc page on the DATETIME format:

    For values specified as strings that include date part delimiters, it is not necessary to specify two digits for month or day values that are less than 10. ‘1979-6-9’ is the same as ‘1979-06-09’. Similarly, for values specified as strings that include time part delimiters, it is not necessary to specify two digits for hour, minute, or second values that are less than 10. ‘1979-10-30 1:2:3’ is the same as ‘1979-10-30 01:02:03’.

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

Sidebar

Related Questions

Is there some way when sending this message to specify that I rather have
I've seen some questions where people have trouble with accessing .NET SOAP web services
I know there are a bunch of other questions on this. The problem I'm
Is there any way using foursquare api or some other location based api to
Is there a way to use the HAVING clause in some other way without
Is there any way to encapsulate an Iframe with some other element to simulate
In some sample codes there are methods and classes declared WITHIN other methods and/or
This question have been asked by several people but my problem seems to be
This is different to the other questions on this topic. I'll try to make
There are some related questions here and here , but they didn't really give

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.