Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 12 total
Thread ShortDataFormat error
Thu, Aug 30 2012 9:01 AMPermanent Link

Ronald

Hi,

In my OnCreate event I set the ShortDateFormat.

procedure TForm1.Form1Create(Sender: TObject);
begin
FormatSettings.DateSeparator:='-';
FormatSettings.ShortDateFormat:='M-d-yyyy';
end;

On start of the app I get the error:

Error in the format string M-d-yyyy (Too many date components).

Am I doing something wrong here?

Greetings,
Ronald
Thu, Aug 30 2012 3:58 PMPermanent Link

William

"Ronald" wrote:

Hi,

In my OnCreate event I set the ShortDateFormat.

procedure TForm1.Form1Create(Sender: TObject);
begin
FormatSettings.DateSeparator:='-';
FormatSettings.ShortDateFormat:='M-d-yyyy';
end;

On start of the app I get the error:

Error in the format string M-d-yyyy (Too many date components).

Am I doing something wrong here?

Try this, to get a clue of what is happening:

procedure TForm1.Form1Create(Sender: TObject);
var
 s: string;
begin
 FormatSettings.DateSeparator:='-';
 s := FormatSettings.ShortDateFormat;
 Label1.Caption := s;
 FormatSettings.ShortDateFormat:= s;
 Application.Desktop.OnResize := DesktopResize;
end;

You will see that the string contains 'M/d/yyyy' (no hyphens) in spite of the setting to FormatSettings.DateSeparator.

Bill
Thu, Aug 30 2012 4:21 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ronald,

<< On start of the app I get the error:

Error in the format string M-d-yyyy (Too many date components). >>

I think it's a bug.  I'll make sure that this is fixed in build 2.

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Aug 30 2012 4:41 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Bill,

<< Try this, to get a clue of what is happening: >>

Actually, Ronald is correct in that you have to specify the date separator
*first*, and then you have to specify the ShortDateFormat.

The problem is with the '-' sign being considered the start of a number by
the parser, and I'll have a fix for this in build 2.

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Aug 31 2012 3:04 AMPermanent Link

Ronald

Thank you, all. Will wait for build 2.

"Tim Young [Elevate Software]"  schreef in bericht
news:6523DE1C-115B-4ACB-8BA2-756E1576DCEF@news.elevatesoft.com...

Ronald,

<< On start of the app I get the error:

Error in the format string M-d-yyyy (Too many date components). >>

I think it's a bug.  I'll make sure that this is fixed in build 2.

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Feb 12 2014 8:31 AMPermanent Link

Matthew Jones

Did this ever get fixed?

I'm getting the error with:

   FormatSettings.ShortDateFormat := 'yyyy-MM-dd';

(I'm seeking ISO formatted dates)

/Matthew Jones/
Wed, Feb 12 2014 8:32 AMPermanent Link

Matthew Jones

'yyyyMMdd' fails with "invalid y component".

/Matthew Jones/
Wed, Feb 12 2014 8:58 AMPermanent Link

Matthew Jones

The workaround is easy of course:

   FormatSettings.ShortDateFormat := 'yyyy MM dd';
   FormatSettings.DateSeparator := '-';

I guess the assignment of a string is quite complicated really.

/Matthew Jones/
Wed, Feb 12 2014 9:09 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Did this ever get fixed? >>

Yes.

<< I'm getting the error with: >>

If you're using a different date separator, then you need to set that
*before* you try to set the date format using the different separator:

  FormatSettings.DateSeparator:='-';
  FormatSettings.ShortDateFormat := 'yyyy-MM-dd';

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Feb 12 2014 9:11 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< 'yyyyMMdd' fails with "invalid y component". >>

Dates *must* use a separator of some kind.

Tim Young
Elevate Software
www.elevatesoft.com

Page 1 of 2Next Page »
Jump to Page:  1 2
Image