Here's a much simpler FirstDay function. I've used it for at about
15 years.
*-----------------------------------------------
procedure BOMDATE
parameters Mdate
* Returns first date of the month
* PC Magazine, March 26, 1996 (P.252)
* Notes: day(date) is the day of the month.
* gomonth(date,n) returns the date advanced n months
return Mdate - day(Mdate) + 1
*-- faster than stuffing '01' into the dtoc()
*-----------------------------------------------
procedure EOMDATE
parameters Mdate
* Returns last date of the month
return gomonth(Mdate - day(Mdate) + 1, 1) - 1
*-- i.e., BOM, then forward one month, then back up one day
*-----------------------------------------------
So we get:
FebDate = <any date in February of the year in question>
IsLeapYear = (day(EOMDATE(FebDate)) = 29)
Dan Covill
On 4/12/2011 3:36 PM, Rafael Copquin wrote:
> 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
_______________________________________________
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.