Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Zeller's congruence to get day of week
#8
This little code calculate the week day and gives the julian date.

Code: (Select All)
Datum: Input "DATE in form MMDDYYYY or nothing to stop"; k$
If Len(k$) <> 8 Then End
M# = Val(Left$(k$, 2)): J# = Val(Mid$(k$, 3, 2)): A# = Val(Right$(k$, 4))
If J# < 1 Or J# > 31 Or M# < 1 Or M# > 12 Then Print " Date not correct": GoTo Datum
GoSub GJ
Print jour$; M#; "/"; J#; "/"; A#; "/ julian-->"; jj#
Print "----------------"
GoTo Datum

GJ: XXJ# = J#: XXA# = A#: XXM# = M#: J# = J# + .5: C# = 1720994.5#: Y# = Int(A# / 100) - 6: If M# < 3 Then A# = A# - 1
M# = M# + 1: If M# < 4 Then M# = M# + 12
If A# > 0 Then If M# < 3 Then A# = A# - 1
jj# = Int(365.25 * A#) + Int(30.6001 * M#) + J# + C# - Y#
If XXA# > 1999 Then jj# = jj# + 1
D# = jj# - 2299162#: D# = jj# / 7 - Int(jj# / 7): D# = Int((D# + .01) * 7)
jour$ = "Monday  Tuesday  WednesdayThursday Friday  Saturday Sunday  "
jour$ = RTrim$(Mid$(jour$, D# * 9 + 1, 9)): J# = XXJ#: M# = XXM#: A# = XXA#: Return
Why not yes ?
Reply


Messages In This Thread
RE: Simple Zeller's congruence to get day of week - by euklides - 09-16-2024, 11:13 AM



Users browsing this thread: 5 Guest(s)