User Tools

Site Tools


mmbasic:quick_day_of_week_and_tiny_too

Quick Day Of Week (and tiny too)

Caution - do not use for dates prior to 01 MAR 2000 - read discussion If you need historical DayofWeek, here is an alternative

This has to be the fastest most compact Day of the Week function I have seen.

credit: TBS user Quazee137 the original thread can be seen here: http://www.thebackshed.com/forum/forum_posts.asp?TID=9281&TPN=2

Function dow(m As Integer,d As Integer,y As Integer) As Integer

'  1       2       3       4       5       6       7
' sun     mon     tue     wed     the     fri     sat

   If m < 3 Then
      m=m + 12
      y=y-1
   End If
   dow = 1 + (d + ((26 * m+1)/10) - (2 * (y\100)) + y + (y\4) + (y\400) ) Mod 7
End Function
mmbasic/quick_day_of_week_and_tiny_too.txt · Last modified: 2024/01/19 09:30 by 127.0.0.1