Converts date values to day of year (DoY) values.
DATE2DOY(date, time)
(doy, yfrac) = DATE2DOY(date, time)
date |
- |
A string, scalar or series of Julian date values. The input dates. Defaults to the current date. |
time |
- |
Optional. A string or series of TOD times, the input times. Defaults to an empty series. |
A series or array of integer or fractional day of year values.
(doy, yfrac) = DATE2DOY(date, time) returns the Day of Year values in doy and the fraction of the year elapsed for each date time input in yfrac.
W1: date2doy("1/1/2030")
W1 == {1}
W1 contains the value 1, indicating 1/1/2030 is the first day of 2030.
W1: date2doy("1/1/2030", "12:00:00")
W1 == {1.5}
W1 contains the value 1.5, indicating "1/1/2030 12:00:00" is the first day plus one half day of 2030.
W1: (doy, yfrac) = date2doy("1/1/2030", "12:00:00");ravel(doy, yfrac)
W1 == {{1.5, 0.001370}}
The first column of W1 contains the value 1.5, indicating "1/1/2030 12:00:00" is the first day and one half of 2030.
The second column contains the value 0.001370, indicating that on "1/1/2030 12:00:00", 0.137% of the year has elapsed.
W2: ymd2date({{2030, 1, 1},
{2030, 2, 1},
{2030, 3, 1},
{2030, 4, 1}})
W3: date2doy(w2)
W3 == {1, 32, 60, 91}
W3 indicates that for 2030, 1/1/2030 is day 1, 2/1/2030 is day 32, 3/1/2030 is day 60 and 4/1/2030 is day 91.
W1: gnorm(1000, 10000);setdate("2030-Jun-01");settime("12:00:00")
W2: getdt(w1)
W3: date2doy(w2)
W4: doy2date(w3)
W1 contains a random series that extends from 6/01/2030 to 9/25/2030.
W2 returns the date time values of each sample of W1.
W3 converts the date time values in W2 to fractional DoY values.
W4 converts the fractional DoY values of W3 back to date time values. The result in W4 is equal to W2 within machine precision.
DATE2DOY converts a date or datetime series to the corresponding day of year (DOY) series.
Each DOY value is an integer from 1 to 366, where 1 corresponds to January 1.
If time is specified, the function returns fractional DOY values ranging from 1.0 to 366.0. The integer portion represents the day of the year and the fractional portion indicates the proportion of that day that has elapsed (0.0 at midnight, 0.5 at noon, etc.).
See DOY2DATE to convert Day of Year values to dates.