this function checks for the last day of the month

FUNCTION LASTDAY
Lparameters tcMonth,tcYear

Local nMonth,nLastDay,nYear

nMonth = Val(tcMonth)
nYear  = Val(tcYear)

nLastDay =  ICase(inlist(nMonth,1,3,5,7,8,10,12) ,31,;
                   InList(nMonth,4,6,9,11)        ,30,;
                   nMonth = 2,Iif(Mod(nYear,4)=0,29,28))

Return nLastDay

Incidentally, to check for a leap year, use the mod function as above

if mod(nYear,4) = 0

    ** it is a leap year, therefore february has 29 days

else

  ** it is not a leap year (only 28 days for february)

endif


Rafael Copquin


El 12/04/2011 18:48, MB Software Solutions, LLC escribió:
> How do you test to see if it's a leap year?  The first thing that comes
> to my mind is checking to see if DATE(nCurrentYearVariable,2,29) throws
> an error or not.  e.g.
>
>     dDate = DATE(nCurrentYearVariable,2,29)
>     lLeapYear = not empty(dDate)
>
> Better ideas?
>

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to