StrFormat2Date Function
Converts a string containing a Date into a DateTime.

Unit
QESBPCSDateTime

Declaration
Function StrFormat2Date(const DateStr: string; const Format: string): TDateTime;

Description
Uses supplied Format instead of ShortDateFormat for the String. If the Item has no month and/or year then the current month and year will be assumed.

ESB2DigitYr contols the different ways in which 2 Digit Years are handled in Str2Date.

edyNone - Nothing is done, left to Delphi to handle.

edyCutOff - the ESB2DigitCutOff is used to decide which century the date lies in. If 1900 + Yr less than ESB2DigitCutOff then it is assumed that 2000 + Yr is wanted, otherwise 1900 + Yr is used.

edyHistoric - asssumes that the yr is this year or earlier.

Parameters
DateStr The String to convert.
Format that the Date is assumed to be in, eg 'DD/MM/YY'.

Category
Date/Time Conversion Routines

Implementation

function StrFormat2Date (const DateStr: string; const Format: string): TDateTime;
var
     Hold: string;
begin
     Hold := ShortDateFormat;
     ShortDateFormat := Format;
     try
          Result := Str2Date (DateStr);
     finally
          ShortDateFormat := Hold;
     end;
End;


HTML generated by Time2HELP
http://www.time2help.com