[fpc-pascal] Why has StrToDate() failing under FPC 2.3.1 (64bit)
Michael Van Canneyt
michael at freepascal.org
Tue Oct 20 12:05:39 CEST 2009
On Tue, 20 Oct 2009, Graeme Geldenhuys wrote:
> On 20/10/2009, Michael Van Canneyt <michael at freepascal.org> >
>> 1. StrToDate uses shortdateformat.
>>
>> 2. StrToDate DOES NOT use shortdateformat to check the actual format;
>> because it accepts only dates of the form N1/N2/N3
>> - it uses ShortDateFormat ONLY to determine the order of y,m,d
>> - it uses DateSeparator to determine the actual date separator to use
>> instead of /
>
> So how come I still can't get this to work... I tried the following
> and various other options. Every single attempt gives me a conversion
> error. How am I supposed to solve this?
Strip the time part.
You are feeding a date/time pair to something that expects ONLY a date.
Michael.
>
>
> var
> s: string;
> d: TDateTime;
> begin
> // ShortDateFormat := 'dd/mm/yyyy';
> // ShortDateFormat := 'dd/mm/yy';
> ShortDateFormat := 'd/m/y';
> DateSeparator := '/';
> // s := '03/06/04 12:45:15:000';
> s := '03/06/2004 12:45:15:000';
> d := StrToDate(s);
>
> end.
>
>
>>
>> You make a common assumption, which is mistaken:
>> StrToDate(DateToStr(date)) generally does not work.
>>
>> Michael.
>> _______________________________________________
>> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
>
>
> --
> Regards,
> - Graeme -
>
>
> _______________________________________________
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://opensoft.homeip.net/fpgui/
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list