Home Forum Contact

 Access World Forums How to calculate Easter for any year
 User Name Remember Me? Password
Mark Forums Read
 Register FAQ Members List Social Groups Top Posters Search Today's Posts

 Thread Tools Rate Thread Display Modes
 07-07-2017, 01:41 PM #1 isladogs Part time moderator     Join Date: Jan 2017 Location: Somerset, UK Posts: 8,875 Thanks: 105 Thanked 2,378 Times in 2,186 Posts How to calculate Easter for any year I mentioned this in another thread earlier today. https://www.access-programmers.co.uk...d.php?t=294618 The function below calculates Easter Sunday for any year. Apparently, that is the first Sunday after the first ecclesiastical full moon that occurs on or after March 21. And there was me thinking they just made it up every year .... Code: ```Public Function GetEasterSunday(Yr As Integer) As Date 'Code taken from http://www.cpearson.com/excel/Easter.aspx Dim D As Integer D = (((255 - 11 * (Yr Mod 19)) - 21) Mod 30) + 21 GetEasterSunday = DateSerial(Yr, 3, 1) + D + (D > 48) + 6 - ((Yr + Yr \ 4 + D + (D > 48) + 1) Mod 7) End Function``` That's it! The code is by Chip Pearson who is, in my view anyway, the Excel equivalent of Allen Browne. I just made minor tweaks to use it in Access Apparently its 'only' guaranteed to be correct between 1900 and 2368 - I've no idea why. After that it doesn't always work However, if you're planning to still be around in 2369, you've got plenty of time to modify the code .. and to post a new version here If you've never checked Chip's site, I strongly recommend it. He also has code to calculate other holiday dates (mainly USA such as Thanksgiving) Lots of other 'goodies' such as 'Programming The VBA Editor' using the 'Microsoft Visual Basic For Applications Extensibility 5.3' reference library http://www.cpearson.com/Excel/MainPage.aspx __________________ If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left. Website links: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts., To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts., To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts., To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Colin Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10, To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts., To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Last edited by isladogs; 07-07-2017 at 01:57 PM.
01-11-2018, 02:42 AM   #2
isladogs
Part time moderator

Join Date: Jan 2017
Location: Somerset, UK
Posts: 8,875
Thanks: 105
Thanked 2,378 Times in 2,186 Posts
More Holiday Dates

The attached database Holidays021 calculates a variety of holiday dates for various different calendars and religions

Word doc included with further explanations

The attached database isn't mine and I don't have the author details.
I know its several years old but that makes it no less useful.

Please let me know if it is yours or you know who wrote it.
Attached Files
 Holidays021.zip (169.6 KB, 90 views)
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

07-10-2018, 04:45 PM   #3
MS ACCESS PROBZZZ
Newly Registered User

Join Date: Jun 2018
Posts: 29
Thanks: 18
Thanked 0 Times in 0 Posts
Re: How to calculate Easter for any year

Is it possible to do this as an Access function instead of VBA so I can store this in a table? Or should I not be storing the date in my table?

The end result I'm looking for is to have a form where I enter "press pitch info" and then select an appropriate holiday name from a combo box. Based on that selection the form should display the correct date of the next instance of this holiday.

So I think I will need a table:
Tbl_Holidays
Holiday_ID
HolidayName
HolidayDate

I only know how to use VBA with forms, not with tables, and can't think of a method for this.

Do you have any pointers?

07-10-2018, 04:54 PM   #4
isladogs
Part time moderator

Join Date: Jan 2017
Location: Somerset, UK
Posts: 8,875
Thanks: 105
Thanked 2,378 Times in 2,186 Posts
Re: How to calculate Easter for any year

You posted to the repository which is a moderated area.
In this case, luckily I saw the post almost as soon as you did it ...

Code:
`Public Function GetEasterSunday(Yr As Integer) As Date`
This is an Access function!
Put the code into a standard module and call it from a form button
Similarly with other similar date calculations

Both the Holidays021 database (see post #2) and the one attached (which was written by Pat Hartman) will give you more idea on how to use date functions in forms

As the holiday dates will not change (for any calendar year), it is perfectly OK to store them in a table if you wish
Attached Files
 UsefulDateFunctions.zip (200.3 KB, 48 views)

__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

 The Following User Says Thank You to isladogs For This Useful Post: MS ACCESS PROBZZZ (07-10-2018)

 Tags chip pearson , easter calculation , vba extensibility

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Access World     Access World News     Site Suggestions     Introduce Yourself     The Watercooler Microsoft Access Discussion     General     Tables     Queries     Forms     Reports     Macros     Modules & VBA     Theory and practice of database design     Access Web Microsoft Access Reference     Access FAQs     Code Repository     Sample Databases     Microsoft Access Tutorials     Microsoft Access User Groups Apps and Windows     SQL Server     Crystal Reports     Visual Basic     VB.NET     Word     Excel     Web Design and Development         ASP and ASP.NET         PHP & MySQL     Windows     Other Software     Hardware Questions and Answers Non-Access Issues     Politics & Current Events     Debates     Gaming     Sports, Health & Fitness     Gadgets     Small Business

 Similar Threads Thread Thread Starter Forum Replies Last Post ajblue Queries 2 10-08-2012 06:54 AM Tini Queries 2 04-26-2011 04:19 PM anthonys Queries 1 08-05-2010 07:49 AM Zandra Queries 3 08-14-2009 06:02 AM SnowPatrol Queries 3 05-02-2006 06:44 AM

All times are GMT -8. The time now is 02:38 PM.

 Microsoft Access Help General Tables Queries Forms Reports Macros Modules & VBA Theory & Practice Access FAQs Code Repository Sample Databases Video Tutorials Featured Forum post Sponsored Links
 Contact Us - Home - Privacy Statement - Top

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World