pvl_date2doy

Determine day of year from year, month of year, and day of month

Contents

Syntax

DOY = pvl_date2doy(Year, Month, Day)

Description

Calculates the day of the year given the year, month of year, and day of month in the Gregorian calendar.

Inputs

Year, Month, and Day must be vectors of equal length. If Year or Month are non-integers, the decimal portion of the values will be dropped (floor function). The calculation utilizes the 400 year cycle for leap years.

Outputs

Note that Day must be >=1 and <32. The calculation does NOT check to ensure that the day of month is valid for a given month. Thus pvl_date2doy(2012, 4, 31) = pvl_date2doy(2012, 5, 1).

Example 1

Determine day of year for January 1, 2012

pvl_date2doy(2012, 1, 1)
ans =

     1

Example 2

Determine day of year for December 31, 2012 (leap year)

pvl_date2doy(2012, 12, 31)
ans =

   366

Example 3

Determine day of year for December 31, 2011 (not a leap year)

pvl_date2doy(2011, 12, 31)
ans =

   365

See Also

pvl_leapyear, pvl_doy2date

Copyright 2014 Sandia National Laboratories