Mathematically predict date of holidays, such as Easter (1 Viewer)

isladogs

MVP / VIP
Local time
Today, 11:22
Joined
Jan 14, 2017
Messages
18,186
Sadly, I cannot see that happening. Eventually the site will come up for renewal.
That is 2019-06-22.

What often happens in such cases is that other people offer to continue hosting the site
 

david.paton

Registered User.
Local time
Today, 04:22
Joined
Jun 26, 2013
Messages
338
I just found out how to do it, I used the date formula =DATE(I30,1,1), where I30 is the year, then the month and day of month, for instance, the above example of new years day.
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:22
Joined
Sep 21, 2011
Messages
14,038
What often happens in such cases is that other people offer to continue hosting the site

That crossed my mind, but somewhere where it could be accessed easily by whoever inherited it.
The problem I would have thought is getting all the pages etc. It appears to have been created in Visual Studio and ASP, none of which I am familiar with.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:22
Joined
May 21, 2018
Messages
8,463
The list of public holidays is almost created, I only have one bit left to make. Any ideas how I can do this as I think I am now over thinking things. I have various public holidays that are on a set day, such as new years day 1,1,xxxx or christmas day 25,12,xxxx. How do I input the current year where the xxxx is?

This is how I do it in my calendar control with US holidays. A lot of our holidays have rules like the first monday of the second week or last monday of the 5th month. Hence the function DayOfNthWeek

Code:
Public Enum HolidayName
  holNew_Years = 1
  holML_King_BDay = 2
  holPresidents_Day = 3
  holEaster = 4
  holMemorial_Day = 5
  holIndependance_Day = 6
  holLabor_Day = 7
  holColumbus_Day = 8
  holVeterans_Day = 9
  holThanksgiving = 10
  holChristmas = 11
End Enum

Public Function GetHoliday(ByVal TheYear As Long, TheHolidayName As HolidayName) As Date
   Dim intWeekDay As Integer
   Dim intDay As Integer
   Dim intMonth As Integer
   'New Years Day
    Select Case TheHolidayName
     Case holNew_Years
       GetHoliday = DateSerial(TheYear, 1, 1)
     Case holML_King_BDay
        '3rd monday of January
        GetHoliday = DayOfNthWeek(TheYear, 1, 3, vbMonday)
     Case holPresidents_Day
        'Presidents Day  3rd Monday of Feb
        GetHoliday = DayOfNthWeek(TheYear, 2, 3, vbMonday)
     Case holMemorial_Day
        GetHoliday = LastMondayInMonth(TheYear, 5)
     Case holIndependance_Day
        GetHoliday = DateSerial(TheYear, 7, 4)
     Case holLabor_Day
        GetHoliday = DayOfNthWeek(TheYear, 9, 1, vbMonday)
     Case holColumbus_Day
        GetHoliday = DayOfNthWeek(TheYear, 10, 2, vbMonday)
     Case holVeterans_Day
         ' Veteranss Day
         ' Although originally scheduled for celebration on November 11,
         ' starting in 1971 Veterans Day was moved to the fourth Monday of October.
         ' In 1978 it was moved back to its original celebration on November 11.
        GetHoliday = DateSerial(TheYear, 11, 11)
     Case holThanksgiving
       GetHoliday = DayOfNthWeek(TheYear, 11, 4, vbThursday)
     Case holChristmas
       GetHoliday = DateSerial(TheYear, 12, 25)
     Case holEaster
       'Not US Federal Holiday
       GetHoliday = EasterUSNO(TheYear)
    End Select
    
End Function

Public Function DayOfNthWeek(intYear As Long, intMonth As Integer, N As Integer, vbDayOfWeek As Integer) As Date
  'Thanksgiving is the 4th thursday in November(11)
  'dayOfNthWeek(theYear,11,4,vbThursday)
   DayOfNthWeek = DateSerial(intYear, intMonth, (8 - Weekday(DateSerial(intYear, intMonth, 1), _
 (vbDayOfWeek + 1) Mod 8)) + ((N - 1) * 7))
End Function

Function LastMondayInMonth(intYear As Long, intMonth As Long) As Date
    'Used for memorial day
    Dim LastDay As Date
    'define last day of the month of interest:
    LastDay = DateSerial(intYear, intMonth + 1, 0)
    'use to get last monday:
    LastMondayInMonth = LastDay - Weekday(LastDay, vbMonday) + 1
End Function


Public Function EasterUSNO(YYYY As Long) As Long
    Dim C As Long
    Dim N As Long
    Dim K As Long
    Dim I As Long
    Dim J As Long
    Dim L As Long
    Dim M As Long
    Dim D As Long
    
    C = YYYY \ 100
    N = YYYY - 19 * (YYYY \ 19)
    K = (C - 17) \ 25
    I = C - C \ 4 - (C - K) \ 3 + 19 * N + 15
    I = I - 30 * (I \ 30)
    I = I - (I \ 28) * (1 - (I \ 28) * (29 \ (I + 1)) * ((21 - N) \ 11))
    J = YYYY + YYYY \ 4 + I + 2 - C + C \ 4
    J = J - 7 * (J \ 7)
    L = I - J
    M = 3 + (L + 40) \ 44
    D = L + 28 - 31 * (M \ 4)
    EasterUSNO = DateSerial(YYYY, M, D)
End Function

And you use it like
Code:
somefield = getHoliday(2018,holMemorial_Day)
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:22
Joined
Sep 21, 2011
Messages
14,038
I just found out how to do it, I used the date formula =DATE(I30,1,1), where I30 is the year, then the month and day of month, for instance, the above example of new years day.

Sorry, I had my Access hat on and a blonde moment.:banghead:
 

Users who are viewing this thread

Top Bottom