On Tue, 20 Oct 2009, Graeme Geldenhuys wrote:

On 20/10/2009, Michael Van Canneyt <mich...@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@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@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to