KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Converting the name of a month into a number
PRODUCT: 4D | VERSION: 2004.1 | PLATFORM: Mac & Win
Published On: February 15, 2005

Here is the method that will convert the name of a month (abbreviation or full) to a number.

  ` Method: MonthNameToNum
  ` Description: Convert a Month name to a number
C_LONGINT($0;$cnt_i)
C_STRING(20;$1;$monthname_t)
$monthname_t:=$1
$cnt_i:=0
Repeat
  $cnt_i:=$cnt_i+1
Until ($monthname_t=Get indexed string(11;$cnt_i)) | ($cnt_i>24)
Case of
  : ($cnt_i>24)
  $cnt_i:=0
  : ($cnt_i>12)
  $cnt_i:=$cnt_i-12
End case
$0:=$cnt_i