Extracts the year from a serial Julian date. <span align="right" style="background-color:99FF99"><strong>Excel: MONTH</strong></span>

You're viewing an older version of this page (#190). View the current version.

View versions (1)

Interface

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

using namespace Units::Date;

Overview

Returns the year contained within a serial Julian date as an integer. This function uses dateYMD, to convert the serial Date into a day/ month/ year, from which the year is returned.

Example 1

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

int main()
{
  printf("\n The year is %d", year(1741667));               // The year is 0056
  printf("\n The year is %d", year(1841667, cal_Julian));   // The year is 0330
  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.
dateSystem
selects which date system should be used (see constants):
Blank
  • cal_Gregorian - n.b. there is an optimised year function for Gregorian dates.
  • cal_Julian - the only sensible mode (for the time being!!)
  • cal_Excel (same as Gregorian)

It may be faster to simply use dateYMD, particularly if you also need the day and year from a date.

GPL Licence — free for non commercial use. See Licence details.

FUNCTION

year

Returns as an integer the Gregorian year for the serial Julian date, nDate. This function performs the following calculation:

a = JulianDate + 32103
(1)
b = \frac{a}{146097}
(2)
c = a\ mod\ 146097
(3)
d = \frac{c}{36525}
(4)
e = c\ mod\ 36525 + d
(5)
Year = 400 \frac{a}{146097} + 100 d + 4 \frac{e}{1461} + \frac{e\ mod\ 1461}{365} - 4800
(6)

where all division are integer divisions with the remainder discarded.

References

www.ortelius.de/kalender/calc_en.php

Example 1

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

void main()
{
  printf("\n The year is %d", year(27325));          // The year is 1974
  printf("\n The year is %d", year(169304));         // The year is 2367
}

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.

If you require the day, month and year from the Julian Date it may be faster to simply use dateYMD, particularly if you need two or more parts of a date.

Author

Will Bateman (Sep 2004)

Interactive Calculator

nDate
Result