Should be easy.
Function MyStrToDate(Astr : String) : TDateTime ;
Begin
Astr := StringReplace(Astr,'-',DateSeparator,[rfReplaceAll]);
Astr := StringReplace(Astr,'/',DateSeparator,[rfReplaceAll]);
result := StrTodate(Astr);
End;
This should work on anny string with anny format.
>> StrTodate('04/11/1955');
>>
>> I have even tried setting the ShortDateFormat to 'm/d/y/' and
>> 'mm/dd/yyyy'.
>
> If you're running on linux, try setting
>
> DateSeparator:='/';
Met vriendelijke groet,
Pieter Valentijn
Delphidreams
http://www.delphidreams.nl
-----Oorspronkelijk bericht-----
Van: Jeff Steinkamp [mailto:[EMAIL PROTECTED]
Verzonden: zaterdag 24 februari 2007 23:23
Aan: [email protected]
Onderwerp: Re: [lazarus] StrToDate error
That is the fix, thanks. Now I have to rewrite the routine to make sure
I can
parse either a '-' or a '/' and set the date separator correctly.
Jeff
----- Original Message -----
From: "Michael Van Canneyt" <[EMAIL PROTECTED]>
To: "Lazarus Mailing List" <[email protected]>
Sent: Saturday, February 24, 2007 08:32
Subject: Re: [lazarus] StrToDate error
>
>
> On Fri, 23 Feb 2007, Jeff Steinkamp wrote:
>
>> Can someone tell me why the following is producing an Econvert
>> Exception?
>>
>> StrTodate('04/11/1955');
>>
>> I have even tried setting the ShortDateFormat to 'm/d/y/' and
>> 'mm/dd/yyyy'.
>
> If you're running on linux, try setting
>
> DateSeparator:='/';
>
> because by default it is set to '-'. After doing that it works fine
> here.
>
> Michael.
>
> _________________________________________________________________
> To unsubscribe: mail [EMAIL PROTECTED] with
> "unsubscribe" as the Subject
> archives at http://www.lazarus.freepascal.org/mailarchives
>
>
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives