Code archives/Algorithms/Get the day of the week

This code has been declared by its author to be Public Domain code.

Download source code

Get the day of the week by Kevin_2004
Short function to work out the day of the week based on a numerical date.
; Get the day of the week example by Prof.
;
Graphics 640,480,32,2
SetBuffer BackBuffer()

Day$=GetDayOfTheWeek(15,04,2004) ; <- Put any date in here

Text 10,10,Day$
Flip
WaitKey()
End


Function GetDayOfTheWeek$(day,month,year)
 ; Returns the day of the week.
 ; day, month & year are integers i.e. 15 04 2004
  a=(14-month)/12
  y=year-a
  m=month+(12*a)-2
  d=(day+y+(y/4)-(y/100)+(y/400)+((31*m)/12))Mod 7  ;Ooouch!
  Select d
    Case 0:Weekday$="Sunday"
    Case 1:Weekday$="Monday"
    Case 2:Weekday$="Tuesday"
    Case 3:Weekday$="Wednesday"
    Case 4:Weekday$="Thursday"
    Case 5:Weekday$="Friday"
    Case 6:Weekday$="Saturday"
    Default:Weekday=""
  End Select
  Return Weekday$
End Function

Comments

Rafery2013
thanks Prof


virtlands2013
That 'Day of the Week' code adds a nice touch to any program thanks to the professor.
This was posted 9 years ago; I wonder if that professor is still around. ?




Code Archives Forum