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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:10:26+00:00 2026-06-14T14:10:26+00:00

Should I be storing a Delphi TDateTIme, or perhaps convert to Unix timestamp first?

  • 0

Should I be storing a Delphi TDateTIme, or perhaps convert to Unix timestamp first? Or mayeb eeven as a string?

How should I declare the column in MySql? As a Double, or DateTime (or Integer if I use Unix timestamp)?

Whta is “correct”, or what is easiest if I want to be able to display a string with “yyyy mm dd hh:mm:ss” (or similar) and also to be able to get an elapsed time from comparing two values?

Btw, the program will only ever be used in one tiemzone – which does not have daylight savings time.

I am confused and can’t seem to find this discussed anywhere. Any helpful URLs?

  • 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-14T14:10:27+00:00Added an answer on June 14, 2026 at 2:10 pm
    1. Should I be storing a Delphi TDateTIme, or perhaps convert to Unix timestamp first?

      Typically, you should do neither: the data types in the database layer ought to be meaningful (as possible) on their own and not depend on your application to interpret them. As @Jim DeLaHunt says, this enables the database to easily manipulate/interpret them from SQL as required (and also enables you to easily access the same data from another application codebase in the future).

      MySQL has five temporal types, only two of which store both a date and a time: DATETIME and TIMESTAMP.

      As others have alluded, the difference comes down to whether you wish to store the timezone – although I find that quite a confusing way of looking at it:

      • TIMESTAMP uses the session’s time_zone variable to convert input into a UTC timestamp and then back again for output: it’s useful for specifying an exact moment in time;

      • DATETIME simply stores the date and time without regard to timezone, much like taking a photograph of a calendar and clock: it’s useful for specifying an event that occurs in the same local time globally.

    2. How should I declare the column in MySql? As a Double, or DateTime (or Integer if I use Unix timestamp)?

      Just as you would declare any other column, you specify the relevant data type after the column name.

      Beware that TIMESTAMP has additional features, such as automatic update, which you may wish to disable in your column declaration if so desired.

    3. Whta is “correct”, or what is easiest if I want to be able to display a string with “yyyy mm dd hh:mm:ss” (or similar) and also to be able to get an elapsed time from comparing two values?

      Using one of the above temporal types, you will be able to do all of this (using date functions as required). The default output of TIMESTAMP and DATETIME types is a string in 'YYYY-MM-DD HH:MM:SS' format.

      In particular, the “elapsed time” from comparing two values could for example be obtained with MySQL’s TIMEDIFF() function:

      SELECT TIMEDIFF(end, start) AS elapsed
      FROM   my_table
      WHERE  ...
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way in Delphi 5 to convert a string to a TDateTime
What column type should I use for storing html content from a website with
What datatype should I choose for storing an IP Address in a SQL Server?
Storing credit card information securely and legally is very difficult and should not be
I need to verify in php that a string should not start or end
How to trim multiple characters at begin and end of string. string should be
How to easy encode and compress URL/e-mail adress to string in PHP? String should
I need to validate file name with following pattern.... File name(string) should not be
Should I create private static final String = Some exception message or leave it
When should I use std::string and when should I use char* to manage arrays

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.