The Decimal Date

Published:

Updated:

Basic Code

____________________________________________________________________________________________________

Function DateDecimal(ByVal Year, ByVal Month, ByVal Day) As Double
Dim a, b, c, n, Leap(2, 12) As Integer
a = 0: b = 0: c = 0: n = 0
Leap(0, 0) = 365: Leap(1, 0) = 366
Leap(0, 1) = 0: Leap(1, 1) = 0
Leap(0, 2) = 31: Leap(1, 2) = 31
Leap(0, 3) = 59: Leap(1, 3) = 60
Leap(0, 4) = 90: Leap(1, 4) = 91
Leap(0, 5) = 120: Leap(1, 5) = 121
Leap(0, 6) = 151: Leap(1, 6) = 152
Leap(0, 7) = 181: Leap(1, 7) = 182
Leap(0, 8) = 212: Leap(1, 8) = 213
Leap(0, 9) = 243: Leap(1, 9) = 244
Leap(0, 10) = 273: Leap(1, 10) = 274
Leap(0, 11) = 304: Leap(1, 11) = 305
Leap(0, 12) = 334: Leap(1, 12) = 335
If (Modulus(Year, 4) = 0) Then a = 1
If (Modulus(Year, 100) = 0) Then b = 1
If (Modulus(Year, 400) = 0) Then c = 1
n = a * b * c - a * b + a 'derived from the boolean math of n = (1 - ((1 - a) + (a * b * (1 - c))))
DateDecimal = Year + ((Leap(n, Month) + Day - 1) / Leap(n, 0))
End Function

Function Modulus(ByVal a As Double, ByVal b As Double) As Long
Modulus = a - b * Int(a / b)
End Function

____________________________________________________________________________________________________

Entry #3,575

Comments

This Blog entry currently has no comments.

Post a Comment

Please Log In

To use this feature you must be logged into your Lottery Post account.

Not a member yet?

If you don't yet have a Lottery Post account, it's simple and free to create one! Just tap the Register button and after a quick process you'll be part of our lottery community.

Register