Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: FoxPro FAQ

Usefull Functions & Procedures

Calculating the date of Easter by Mike Lewis
Posted: 30 Jun 03 (Edited 16 Nov 06)

In the modern Gregorian calendar, Easter Day is 'the first Sunday after the first full moon on or after the vernal equinox'. At first glance, it seems impossible to calculate that date programmatically. However, the following VFP function will do the job.


* Calculates the date of Easter for a given year.
* Accepts years in the range 100 to 9999. However,
* for years before the adoption of the Gregorian
* Calendar (1582 - 1587 in much of Europe, 1752 in
* Britain and North America) the calculation
* is inappropriate.


IF EMPTY(tnYear) OR NOT BETWEEN(tnYear,100,9999)
  ERROR "Invalid year for Easter calculation"

LOCAL lnCentury, lnG, lnI, lnK, lnJ, lnL
LOCAL lnEasterDay, lnEasterMonth

lnCentury = INT(tnYear/100)
lnG = MOD(tnYear, 19)
lnK = INT((lnCentury - 17)/25)
lnI = MOD((lnCentury - INT(lnCentury/4) - ;
  INT((lnCentury - lnK)/3) + 19*lnG + 15), 30)
lnI = lnI - INT(lnI/28) * ((1 - INT(lnI/28) * ;
  (INT(29/(lnI+1)) * (INT((21-lnG)/11)))))
lnJ = MOD((tnYear + INT(tnYear/4) + lnI + 2 - ;
  lnCentury + INT(lnCentury/4)), 7)
lnL = lnI - lnJ
lnEasterMonth = 3 + INT((lnL + 40)/44)
lnEasterDay = lnL + 28 - 31*INT(lnEasterMonth/4)

RETURN DATE(tnYear,lnEasterMonth,lnEasterDay)


Mike Lewis
Edinburgh, Scotland

Back to Microsoft: FoxPro FAQ Index
Back to Microsoft: FoxPro Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close