Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is there a function that returns the number of days in a
Message
 
 
À
10/11/2000 16:46:14
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00440276
Message ID:
00440535
Vues:
12
>>>>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform