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

  • Home
  • SEARCH
  • 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 5844985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:22:14+00:00 2026-05-22T12:22:14+00:00

I have to store date values ( TDateTime ) in a string format. What

  • 0

I have to store date values (TDateTime) in a string format. What is the best way to do this? I considered the following approaches:

FloatToStr : looses precision, depends on locale settings

`FloatToStr’ with format settings : looses precision

DateTimeToStr : depends on locale settings

DateTimeToStr with format settings : ?

Are there any other alternatives? How do they compare in terms of

  • Size in memory
  • Independence of locale settings
  • Precision
  • 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-05-22T12:22:15+00:00Added an answer on May 22, 2026 at 12:22 pm

    Use ISO-8601 format, as detailed in http://en.wikipedia.org/wiki/ISO_8601

    If you need to save storage space, you can use the “compact” layout, e.g. ‘20090621T054523’.

    You can use e.g. FormatDateTime('yyyymmddThhnnss',aDateTime) to produce it.

    About time zone and localisation (from wikipedia):

    There are no time zone designators in ISO 8601. Time is only represented as local time or in relation to UTC.

    If no UTC relation information is given with a time representation, the time is assumed to be in local time. While it may be safe to assume local time when communicating in the same time zone, it is ambiguous when used in communicating across different time zones. It is usually preferable to indicate a time zone (zone designator) using the standard’s notation.

    So you should better convert the time into UTC, then append ‘Z’ at the end of the timestamp. Or use +hh/-hh according to your local time zone. The following times all refer to the same moment: “18:30Z”, “22:30+04”, “1130-0700”, and “15:00-03:30”.

    For a better resolution, you can add sub-second timing by adding a fraction after either a comma or a dot character: e.g. to denote “14 hours, 30 minutes, 10 seconds and 500 ms”, represent it as “14:30:10,5”, “143010,5”, “14:30:10.5”, or “143010.5”. You can add several decimals to increase resolution.

    If you need fast Iso8601 conversion routines (working with UTF-8 content), take a look at the corresponding part in SynCommons.pas. It’s much faster than the default SysUtils functions.

    PS:

    If your purpose is just to store TDateTime as text in a pure Delphi application, you can use a not standard but fast:

    function DateTimeToText(const aDateTime: TDateTime): string;
    begin
      result := IntToStr(PInt64(@aDateTime)^);
    end;
    
    function TextToDateTime(const aText: string): TDateTime;
    begin
      PInt64(@result)^ := StrToInt64Def(aText,0);
    end;
    

    Using the Int64 binary layout of TDateTime/double memory structure will be faster than any other floating-point related conversion.

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

Sidebar

Related Questions

I have the following table called [Store_Sales] - Store Date Sales 1 23/04 10000
I have a DateTime which I want to store in a Date MySQL column.
I have a stored procedure that receives a date value like this: @AsOf date
I have a single user java program that I would like to have store
I have to store blog style comments in a database. Each comment can have
In the application I am developing I have to store the time some particular
If all of my __init__.py files are empty, do I have to store them
I have classes that store data, and methods to go get data for individual
Let's say I have I have an online store with a shopping cart feature
I have lots of article store in MS SQL server 2005 database in a

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.