Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/RTL/Delphi/Date - Time    [ Add a report in this area ]  
Report #:  23301   Status: Open
StrToDateTime does not work for mmm months
Project:  Delphi Build #:  10.0.2166.28377
Version:    10.0 Submitted By:   Dan Miser
Report Type:  Suggestion / Enhancement Request Date Reported:  1/9/2006 5:38:42 PM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   152897
Resolution: Deferred to Next Rel (Resolution Comments) Resolved in Build: :
Duplicate of:  None
Voting and Rating
Overall Rating: (7 Total Ratings)
4.71 out of 5
Total Votes: 6
Description
None
Steps to Reproduce:
Go to regional settings and change date format to one of the ones specified.
Try to convert a string in the valid format to a date and you will get an error
"... invlaid date time ..."

Using yyyy-MMM-dd, the following test program raises an exception error.

program Test;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  Date: TDateTime;
  S: String;

begin
  S := '2004-Jun-07';
  Date := StrToDate(S);
  WriteLn(Date);
end.
Workarounds
Call VarToDateTime instead of StrToDateTime
Attachment
TimeTest.zip
Comments

Steven Kamradt at 1/11/2006 6:41:17 AM -
This is not limited to only mmm-dd-yyyy formats, but also international date formats with mmm as the month name.  Any solution should handle foreign month names (based on regional settings) in addition to the standard english month names.

Remco Kapinga at 2/3/2006 5:34:45 AM -
Using a computers regional settings may be incorrect.

For example, reading dates from a file created by another computer (using different time format settings) can lead to incorrect data.

Deborah Pate at 1/12/2006 11:03:06 AM -
And to mmmm formats as well.

Sebastian Modersohn at 9/30/2006 1:53:44 PM -
I'm surprised that this report got opened, since several almost identical reports (QC 27571, 7364 and 4047) got closed with "as designed". Note that this limitation of StrToDate is documented!

ms-help://borland.bds4/bds4win32api_win32/html/DelphiWin32_SysUtilsStrToDateRoutine.htm

clearly states "S must consist of two or three numbers, ..."

Server Response from: ETNACODE01