Computes the day of the week (Sunday through to Monday), for the specified serial Julian date.

View versions (1)

Interface

#include <codecogs/units/date/dayofweek.h>

using namespace Units::Date;

Calculates the week day from a serial Julian date. This is correct for both the Gregorian and Julian calendar. The solution is merely:

DayOfWeek = (nDate+1)\ mod\ 7 + 1
(1)

Example 1

#include <stdio.h>
#include <codecogs/units/date/dayofweek.h>
#include <codecogs/units/date/date.h>
using namespace Units::Date;

int main()
{
  for(int i=10;i<20;i++)
  {
    int adate=date(2004, 10, i);
    printf("\n %d October 2004 is %d day of week", i, dayOfWeek(adate));
  }
  return 0;
}

Parameters

nDate
is a serial number of days from 24 November 4714 BC (1 January 4713BC in the Julian Calendar) - also known as the Julian Period.
type
defines the output style for the day of the week
Blank
  • Type=1 (default) : return contains numbers 1 (Sunday) through 7 (Saturday).
  • Type=2 : return contains numbers 1 (Monday) through 7 (Sunday).
  • Type=3 : return contains numbers 0 (Monday) through 6 (Sunday).
GPL Licence — free for non commercial use. See Licence details.

Interactive Calculator

nDate
type
Result