×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*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.

# 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.

#### CODE

FUNCTION Easter
* 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.

LPARAMETERS tnYear

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

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)

ENDFUNC

Mike Lewis
Edinburgh, Scotland
www.ml-consult.co.uk

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

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:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!