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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:27:14+00:00 2026-05-17T01:27:14+00:00

Is there any way in Delphi 5 to convert a string to a TDateTime

  • 0

Is there any way in Delphi 5 to convert a string to a TDateTime where you can specify the actual format to use?

I’m working on a jobprocessor, which accepts tasks from various workstations. The tasks have a range of parameters, some of which are dates, but (unfortunately, and out of my control) they’re passed as strings. Since the jobs can come from different workstations, the actual datetime format used to format the dates as a string might (and, of course, actual do) differ.

Googling around, the only quick solutions I found was to sneakily change the ShortDateFormat variable, and restore it to its original value afterwards. Since ShortDateFormat is a global variable, and I’m working in a threaded environment the only way this would work is by synchronizing every access to it, which is completely unacceptable (and undoable).

I could copy the library code from the SysUtils unit into my own methods, and tweak them to work with a specified format instead of the global variables, but I’m just wondering if there’s something more adequate out there that I missed.

UPDATE

To put it more succinctly:

I need something like StrToDate (or StrToDateTime), with the added option of specifying the exact format it should use to convert the string to a TDateTime.

  • 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-17T01:27:15+00:00Added an answer on May 17, 2026 at 1:27 am

    I created such routine for FreePascal’s dateutils unit, and it should easy to port, if porting is needed at all.

    Code:

    http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/rtl-objpas/src/inc/dateutil.inc?revision=30628&view=co

    (code is the last (huge) procedure at the end of the file)

    documentation:

    http://www.freepascal.org/docs-html/rtl/dateutils/scandatetime.html

    Note that it is not a complete inverse of formatdatetime, and it has some extensions:

    • An inverse of FormatDateTime is not 100% an inverse, simply because one can put e.g. time tokens twice in the format string,and scandatetime wouldn’t know which time to pick.

    • Strings like hn can’t be reversed safely. E.g. 1:2 (2 minutes after 1) delivers 12 which is parsed as 12:00 and then
      misses chars for the “n” part.

      • trailing characters are ignored.
      • no support for Eastern Asian formatting characters since they are windows only.
      • no MBCS support.
    • Extensions

      • #9 eats whitespace.
      • whitespace at the end of a pattern is optional.
      • ? matches any char.
      • Quote the above chars to really match the char.

    (I believe these comments are slightly outdated in the sense hat some Asian support was added later but I am not sure)

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

Sidebar

Related Questions

Using Delphi 2009 on Windows XP to develop desktop application. Is there any way
I need to use the advantages of delphi sets like in in c++, but
I'm trying to pass a string from C# to Delphi built DLL. Delphi DLL
I can find two separate setting in the Delphi (XE) IDE that affect the
I have a calculation algorithm in Delphi with a number of different options, and
I have an old databasefile from an application written in Delphi. My task is
I am using Delphi 2010 to build a Win32 GUI application running on Windows
Although it is comparatively hard to write in C++ than in Pascal I'm really
A little background of the program: The program uses a tabbed interface to work
Say I have got a program that hogs the processor and/or hard disk to

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.