3.5.1.2.3 Datepart

Description

The datepart function takes a Julian-day value d (double) and returns that portion identified by specifier datepart$. Optional parameter n applies only to datepart$ = ww or w.


See this note.

Syntax

Datepart(datepart$, d [, n])

Parameters

d

is a Julian-day value which can include date and time.

datepart$

is the portion of the Julian-day value specified by one of the following:
datepart$ Unit
yyyy year
q quarter
m month
y day of the year
d day of the month
ww week of the year
w day (number) of the week
h hour
n minute
s second
ms milliseconds
do date only
(time portion removed)
to time only
(date portion removed). Return time as fraction of a day.
dyt day of year, with time as fraction of day


n

is a optional integer value that specifies start of the week:
0 (default) Returns 0 (Sunday) through 6 (Saturday)
1 Returns 1 (Sunday) through 7 (Saturday)
2 Returns 0 (Monday) through 6 (Sunday)
3 Returns 1 (Monday) through 7 (Sunday)

Return

Portion of the Julian-day value returned as a double.

Example

datepart(yyyy, 2457360.5107885)=; // returns 2015
datepart(y, Today())=; // returns the day number of the current year
datepart(w, 2457360.5107885, 1)=; // returns 6
datepart(w, 2457360.5107885)=; // returns 5

See Also