As many of you may know, I have written both a Lotto 649 and a Lotto Max program. One of the things I wanted to do was to automatically enter the next draw date for the next 40 years into the future. Now that poses a unique problem, not only have you got leap years , different month lengths, and 2 draws a week, in Lotto 649 its on Wednesdays and Fridays. In Lotto Max , up until the 17th of May 2019, it was one draw a week with 7 numbers and a bonus number , but after that it changed to 2 draws a week with 50 numbers instead of 49. Quite a problem, both programs are sorta finished, the Lotto Max program needs the data for the day of the week after the last month. What I am showing you is how I got around all of that. A lot of if then statements, but does anyone know of a mathematical formula that will take into account 2 draws, one on Tuesday, and the other on Friday? Oh did I tell you that you also have to adjust for the 28-29-30-31 day months and figure out what day the draw falls on with each month?
Here is an idea of how I did it, the program sample is long, as there is 40 years of data for each month. See for yourself.
calculatedayofweek:
'Find Day of the Week
n = 0: n1 = 0: n2 = 0: n3 = 0: n4 = 0
n1 = FIX(3 * (m + 1) / 5)
n2 = FIX(y / 4)
n3 = FIX(y / 100)
n4 = FIX(y / 400)
n = dy + (2 * m) + n1 + y + n2 - n3 + n4 + 2
day1 = n MOD 7
IF dayflag = 0 THEN
END IF
RETURN
add3or4days:
dayflag = 1
GOSUB rollover
RETURN
rollover:
dayflag = 0
GOSUB calculatedayofweek
GOSUB rollover2
IF day1 = 6 AND count = 0 THEN
IF rollover = 0 THEN
adddays = 4
dy = dy + adddays
ELSEIF rollover = 1 THEN
adddays = 4
dy = dy + adddays + adjust
END IF
ELSEIF day1 = 5 AND count = 0 THEN
IF rollover = 0 THEN
adddays = 4
dy = dy + adddays
ELSEIF rollover = 1 THEN
adddays = 4
dy = dy + adddays + adjust
END IF
ELSEIF day1 = 4 AND count = 0 THEN
IF rollover = 0 THEN
adddays = 3
dy = dy + adddays
ELSEIF rollover = 1 THEN
adddays = 3
dy = dy + adddays + adjust
END IF
ELSEIF day1 = 4 AND count = 0 THEN
IF rollover = 0 THEN
adddays = 3
dy = dy + adddays
ELSEIF rollover = 1 THEN
adddays = 3
dy = dy + adddays + adjust
END IF
ELSEIF day1 = 3 AND count = 0 THEN
IF rollover = 0 THEN
adddays = 3
dy = dy + adddays
ELSEIF rollover = 1 THEN
adddays = 3
dy = dy + adddays + adjust
END IF
ELSEIF day1 = 2 AND count = 0 THEN
IF rollover = 0 THEN
adddays = 3
dy = dy + adddays
ELSEIF rollover = 1 THEN
adddays = 3
dy = dy + adddays + adjust
END IF
ELSEIF day1 = 1 AND count = 0 THEN
IF rollover = 0 THEN
adddays = 3
dy = dy + adddays
ELSEIF rollover = 1 THEN
adddays = 3
dy = dy + adddays + adjust
END IF
ELSEIF day1 = 0 AND count = 0 THEN
IF rollover = 0 THEN
adddays = 3
dy = dy + adddays
ELSEIF rollover = 1 THEN
adddays = 3
dy = dy + adddays + adjust
END IF
END IF
IF adddays = 4 THEN day8 = 3
IF adddays = 3 THEN day8 = 6
adjust = 0
dayflag = 1
GOSUB calculatedayofweek
rollover2:
IF y = 2019 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 2: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 2: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 2: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2020: m = 1: dy = 3: rollover = 1: adjust = 0
END IF
IF y = 2020 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 4: rollover = 1: adjust = 0
IF dy > 29 AND m = 2 THEN m = 3: dy = 3: rollover = 1: adjust = 2
IF dy > 31 AND m = 3 THEN m = 4: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 3: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 4: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2021: m = 1: dy = 1: rollover = 1: adjust = 0
END IF
IF y = 2021 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 2: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 2: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 4: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 3: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2022: m = 1: dy = 4: rollover = 1: adjust = 0
END IF
IF y = 2022 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 2: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 2: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 4: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 3: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2023: m = 1: dy = 4: rollover = 1: adjust = 0
END IF
IF y = 2023 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 1: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 1: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 2: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 4: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2024: m = 1: dy = 3: rollover = 1: adjust = 0
END IF
IF y = 2024 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 3: rollover = 1: adjust = 0
IF dy > 29 AND m = 2 THEN m = 3: dy = 2: rollover = 1: adjust = 2
IF dy > 31 AND m = 3 THEN m = 4: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 3: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 4: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 4: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2025: m = 1: dy = 1: rollover = 1: adjust = 0
END IF
IF y = 2025 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 1: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 1: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 4: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 2: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2026: m = 1: dy = 3: rollover = 1: adjust = 0
END IF
IF y = 2026 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 4: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 4: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 1: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 4: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2027: m = 1: dy = 3: rollover = 1: adjust = 0
END IF
IF y = 2027 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 3: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 3: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 4: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2028: m = 1: dy = 1: rollover = 1: adjust = 0
END IF
IF y = 2028 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 2: rollover = 1: adjust = 0
IF dy > 29 AND m = 2 THEN m = 3: dy = 1: rollover = 1: adjust = 2
IF dy > 31 AND m = 3 THEN m = 4: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 2: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 4: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2029: m = 2: dy = 3: rollover = 1: adjust = 0
END IF
IF y = 2029 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 3: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 3: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 4: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 4: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2030: m = 1: dy = 2: rollover = 1: adjust = 0
END IF
IF y = 2030 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 2: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 2: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 3: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 4: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 4: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2031: m = 1: dy = 1: rollover = 1: adjust = 0
END IF
IF y = 2031 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 1: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 1: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 4: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 2: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2032: m = 1: dy = 3: rollover = 1: adjust = 0
END IF
IF y = 2032 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 4: rollover = 1: adjust = 0
IF dy > 29 AND m = 2 THEN m = 3: dy = 3: rollover = 1: adjust = 2
IF dy > 31 AND m = 3 THEN m = 4: dy = 4: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 4: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2033: m = 1: dy = 1: rollover = 1: adjust = 0
END IF
IF y = 2033 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 2: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 2: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 4: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 3: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2034: m = 1: dy = 4: rollover = 1: adjust = 0
END IF
IF y = 2034 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 1: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 1: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 2: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 4: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2035: m = 1: dy = 3: rollover = 1: adjust = 0
END IF
IF y = 2035 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 3: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 3: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 4: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 4: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 1: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2036: m = 1: dy = 2: rollover = 1: adjust = 0
END IF
IF y = 2036 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 2: rollover = 1: adjust = 0
IF dy > 29 AND m = 2 THEN m = 3: dy = 1: rollover = 1: adjust = 2
IF dy > 31 AND m = 3 THEN m = 4: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 4: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 2: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2037: m = 1: dy = 3: rollover = 1: adjust = 0
END IF
IF y = 2037 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 4: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 4: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 4: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 1: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 4: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2038: m = 1: dy = 2: rollover = 1: adjust = 0
END IF
IF y = 2038 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 3: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 3: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 4: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2039: m = 1: dy = 1: rollover = 1: adjust = 0
END IF
IF y = 2039 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 2: rollover = 1: adjust = 0
IF dy > 28 AND m = 2 THEN m = 3: dy = 2: rollover = 1: adjust = 3
IF dy > 31 AND m = 3 THEN m = 4: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 4: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 3: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2040: m = 1: dy = 4: rollover = 1: adjust = 0
END IF
IF y = 2040 THEN
IF dy > 31 AND m = 1 THEN m = 2: dy = 1: rollover = 1: adjust = 0
IF dy > 29 AND m = 2 THEN m = 3: dy = 1: rollover = 1: adjust = 2
IF dy > 31 AND m = 3 THEN m = 4: dy = 4: rollover = 1: adjust = 0
IF dy > 30 AND m = 4 THEN m = 5: dy = 2: rollover = 1: adjust = 1
IF dy > 31 AND m = 5 THEN m = 6: dy = 2: rollover = 1: adjust = 0
IF dy > 30 AND m = 6 THEN m = 7: dy = 4: rollover = 1: adjust = 1
IF dy > 31 AND m = 7 THEN m = 8: dy = 1: rollover = 1: adjust = 0
IF dy > 31 AND m = 8 THEN m = 9: dy = 1: rollover = 1: adjust = 0
IF dy > 30 AND m = 9 THEN m = 10: dy = 3: rollover = 1: adjust = 1
IF dy > 31 AND m = 10 THEN m = 11: dy = 3: rollover = 1: adjust = 0
IF dy > 30 AND m = 11 THEN m = 12: dy = 1: rollover = 1: adjust = 1
IF dy > 31 AND m = 12 THEN y = 2041: m = 1: dy = 2: rollover = 1: adjust = 0
END IF
RETURN
Now that is how I did it, but I still have to plug in the right data for each month starting after 2020, will be doing that tomorrow, but thought I would give you an idea of how I handled it.
Can anyone thing of a better way?
Russ Campbell