Try using VarToDateTime. It takes a variant parameter, so you just 
pass in a string. Being a variant its too slow for doing a lot of 
calculations, but for a gui it is fantastic as it can handle all 
these formats without blinking:
'oct 23 00'
'23 oct 00'
'23-10/00'
'23/10 2000'
'10/23/00'
'23 00 oct'
'23 octob 00'
all convert to '23/10/2000'
'october 2000'
'00 oct'
both convert to '1/10/2000'
and you only need to trap the EVariantError exception.

Cheers.

Paul Heinz wrote:
> 
> 
> <PET-PEEVE>
> 
> The Delphi StrToDate function is a piece of crap. It forces the user to type
> dates in the way the machine wants it and throws exceptions at the drop of a
> hat.
> 
> I replaced it with a Str2Date function which has the code take what the user
> types and determines a date from it if this can be done un-ambigously. It
> doesn't care about seperators (they can be anything or missing),
> alphanumeric vs numeric months, partial vs full years, or missing bits of
> the date. All it needs to know is which order the date portions come in i.e.
> DMY (UK), MDY (US) or YMD (ISO) date ordering which it parses out of the
> ShortDateFormat.
> 
> I'm not especially fond of StrToFloat or StrToInt either. They were for the
> high-jump as well.
> 
> </PET-PEEVE>
> 
> TTFN,
>   Paul.
> 
> ---------------------------------------------------------------------------
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to