MonthName2Month Function
Given a Month Name this routines searches through the Short and then Long Month Names supplied in the Registry to do a Left Match, and then return the Month Number.

Unit
QESBPCSDateTime

Declaration
Function MonthName2Month(const MonthName: string): Word;

Description
So for English Names, 'Ma' would return 3 for 'March' .

Parameters
MonthName Name of the Month to search for.

Returns
the Month Number, 1 through 12 - 0 implies not found.

Category
Date/Time Conversion Routines
Month Based Arithmetic Routines

Implementation

function MonthName2Month (const MonthName: string): Word;
var
     I: Integer;
     Len: Integer;
     MN: string;
begin
     Result := 0;
     if MonthName = '' then
          Exit;
     Len := Length (MonthName);
     MN := AnsiUpperCase (MonthName);
     for I := 1 to 12 do
     begin
          if AnsiUpperCase (LeftStr (ShortMonthNames [I], Len)) = MN then
          begin
               Result := I;
               Exit;
          end;
     end;
     for I := 1 to 12 do
     begin
          if AnsiUpperCase (LeftStr (LongMonthNames [I], Len)) = MN then
          begin
               Result := I;
               Exit;
          end;
     end;
End;


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