Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a function that returns the number of days in a
Message
 
 
To
10/11/2000 16:46:14
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00440276
Message ID:
00440535
Views:
19
>>>>Is there a function that returns the number of days in a month?
Anybody see anything wrong with:
CLEAR
FOR iyear = 1999 to 2001
   FOR iMonth = 1 TO 12
     iDaysInMonth = fDaysInMonth2( iYear, iMonth )
      ? DATE( iYear, iMonth, iDaysInMonth ), iDaysInMonth
   NEXT iMonth
   ?
NEXT iYear
RETURN .T.

**************************************
FUNCTION fDaysInMonth( iYear, iMonth )
**************************************
   IF iMonth < 12
      dEndOfMOnth = DATE( iYear, iMonth+1, 1 ) -1 
   ELSE
      dEndOfMOnth = DATE( iYear+1, 1, 1 ) -1 
   ENDIF
   RETURN DAY( dEndOfMOnth )
   ENDFUNC  && fDaysInMonth( iYear, iMonth )

*- Or as a one-liner:

***************************************
FUNCTION fDaysInMonth2( iYear, iMonth )
***************************************
   RETURN DAY( IIF( iMonth < 12 ;
                   , DATE( iYear, iMonth+1, 1 ) -1  ;
                   , DATE( iYear+1, 1, 1 ) -1  ))
   ENDFUNC  && fDaysInMonth( iYear, iMonth )
censored.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform