image thumbnail

Date to Decimal Day of Year

version (1.62 KB) by Anthony Kendall
Convert a vector of MATLAB serial dates to decimal days since the start of the year.


Updated 28 Apr 2009

View License

This function calculates the decimal day of the year of the input vector of dates. The dates must be in MATLAB serial date format.

For example, for datestr(now), MATLAB produces: "18-Jan-2008 14:33:27". The output of this function, called "date2doy" yields-
date2doy(now): "18.60662".

There are two outputs, the decimal date (can be a vector), and the fraction of the year completed by that date. From the example above, the fraction of the year is: "0.0481"

This function is very fast, and is ideal for embedding in larger applications that call date2doy many times.

Cite As

Anthony Kendall (2022). Date to Decimal Day of Year (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: Day of Year to MATLAB date, deseason

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!