Table of Contents

Search

Taskflows

Taskflows

getDatePart

getDatePart

Returns the specified part of a date as an integer value. Therefore, if you create an expression that returns the month portion of the date, and pass a date such as Apr 1 1997 00:00:00, getDatePart returns 4.

Syntax

date:getDatePart(xs:dateTime('date'), 'format')
You must manually add the xs:dateTime phrase and enclose the date values within single quotation marks.
The following table describes the arguments:
Argument
Required/ Optional
Description
date
Required
Date/Time data type.
You can enter any valid transformation expression.
format
Required
A format string that specifies the portion of the date value that you want to return. Enclose format strings within single quotation marks, for example, 'mm'. The format string is not case sensitive.
For example, if you pass the date Apr 1 1997 to getDatePart, the format strings 'Y', 'YY', 'YYY', or 'YYYY' all return 1997.

Return Value

Integer representing the specified part of the date.
NULL if a value passed to the function is NULL.

Examples

The following expressions return the hour for each date in the DATE_SHIPPED column. 12:00:00AM returns 0 because the default date format is based on the 24 hour interval:
date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'HH') date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'HH12') date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'HH24')
The following table lists some sample values and return values:
DATE_SHIPPED
RETURN VALUE
Mar 13 1997 12:00:00AM
0
Sep 2 1997 2:00:01AM
2
Aug 22 1997 12:00:00PM
12
June 3 1997 11:30:44PM
23
NULL
NULL
The following expressions return the day for each date in the DATE_SHIPPED column:
date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'D') date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'DD') date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'DDD') date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'DY') date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'DAY')
The following table lists some sample values and return values:
DATE_SHIPPED
RETURN VALUE
Mar 13 1997 12:00:00AM
13
June 3 1997 11:30:44PM
3
Aug 22 1997 12:00:00PM
22
NULL
NULL
The following expressions return the month for each date in the DATE_SHIPPED column:
date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'MM') date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'MON') date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'MONTH')
The following table lists some sample values and return values:
DATE_SHIPPED
RETURN VALUE
Mar 13 1997 12:00:00AM
3
June 3 1997 11:30:44PM
6
NULL
NULL
The following expressions return the year for each date in the DATE_SHIPPED column:
date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'Y') date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'YY') date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'YYY') date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'YYYY')
The following table lists some sample values and return values:
DATE_SHIPPED
RETURN VALUE
Mar 13 1997 12:00:00AM
1997
June 3 1997 11:30:44PM
1997
NULL
NULL

0 COMMENTS

We’d like to hear from you!