Developer Documentation Library > UNICOM Intelligence Function Library > Date and time functions > DatePart
 
DatePart
Returns a specified part of a given date.
Syntax
DatePart(<value>, <interval>)
Parameters
<value>
Type: Date
The date of which you want to return a part.
<interval>
Type: Text
Defines the part of the date that is to be returned. See Value of Interval.
(return)
Type: Long
The specified part of the date.
Notes
If you use the function in an SQL query, use single quotation marks (' ') instead of double quotation marks (" ") when specifying the Interval parameter.
<value> is interpreted according to the input locale.
In some locales, when you use the ww option to return the week of the year, the week number for the first days of January might be returned as 53 and for the last days of December it might be returned as 1. For example, if the locale defines the first day of the week as Monday and the first week of the year as the first full week, the week number is returned as 53 for the first few days in a year in which the first Monday falls on January 7.
Example
The following example returns the year from the system date (which is in turn returned by the Now function). For example, on 31 January 2002, this example returns 2002.
DatePart(Now(), "yyyy")
For an example of using DatePart with the WeekdayName function to return the name of the day on which an interview was completed, see WeekdayName
See also
DateAdd
Date and time functions