Find the Day From a Date

Using a combination of date functions, you can determine the day of the week for a particular given date. For example, where the date of an incident is 2020-01-28, you could determine that this date was a Tuesday.

An interview screen showing the calculation of the day of the week from an input date

The rule table used to find the day from a date is shown below:

the day of the week
"Monday"

DayDifference(NextDayOfTheWeek(the date of the incident,"Monday"), the date of the incident) = 0

"Tuesday"

DayDifference(NextDayOfTheWeek(the date of the incident,"Tuesday"), the date of the incident) = 0

"Wednesday"

DayDifference(NextDayOfTheWeek(the date of the incident,"Wednesday"), the date of the incident) = 0

"Thursday"

DayDifference(NextDayOfTheWeek(the date of the incident,"Thursday"), the date of the incident) = 0

"Friday"

DayDifference(NextDayOfTheWeek(the date of the incident,"Friday"), the date of the incident) = 0

"Saturday"

DayDifference(NextDayOfTheWeek(the date of the incident,"Saturday"), the date of the incident) = 0

"Sunday"

DayDifference(NextDayOfTheWeek(the date of the incident,"Sunday"), the date of the incident) = 0

uncertain otherwise

The way this work is as follows:

  • The NextDayOfTheWeek function is used to get the date of the next Monday, Tuesday, Wednesday and so on after the input date ("the date of the incident"). Importantly, the calculation of the NextDayOfTheWeek includes the input date, so if, for example, the input date is a Tuesday (for example, 2020-01-28), the next Tuesday is calculated to be 2020-01-28.
  • That NextDayOfTheWeek date is then used with the DayDifference function and the input date ("the date of the incident") to determine the number of whole days between the two dates. When the NextDayOfTheWeek date is the same date as the input date, the difference will be 0.
  • The rule table then sets the day of the week based on which particular condition has a DayDifference of 0.