KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Retrieving the maximum number of days for a given month
PRODUCT: 4D | VERSION: 2003.2 | PLATFORM: Mac & Win
Published On: December 18, 2003

Here is a simple method that will return the maximum number of days in a given month. The result is based on the date value that is passed into the method.

` Project Method: GetMaxNumOfDay
` Description: Return the maximum number of days of a month

C_DATE($1)
C_LONGINT($0;$month;$year)

$month:=Month of($1)
$year:=Year of($1)

Case of
  : ($month=1)
    $0:=31
  : ($month=2)
    If(Dec($year/4)>0)
      $0:=28
    Else
      $0:=29
    End if
  : ($month=3)
    $0:=31
  : ($month=4)
    $0:=30
  : ($month=5)
    $0:=31
  : ($month=6)
    $0:=30
  : ($month=7)
    $0:=31
  : ($month=8)
    $0:=31
  : ($month=9)
    $0:=30
  : ($month=10)
    $0:=30
  : ($month=11)
    $0:=30
  : ($month=12)
    $0:=31
End case