Function list
lastNDate
-
Usage: Determines the start date of the period for the last N days.
-
Parameters:
-
(Required) currentDate: The current date in the format
yyyyMMdd. -
(Required) preDays: The number of days to look back, specified as an integer.
-
(Required) format: The date format, which is
yyyyMMdd.
-
-
Return value:
-
The start date of the last N days period, returned as a string in the format
yyyyMMdd.
-
-
Example:
-
lastNDate('20180118', 7,'yyyyMMdd')yields20180112.
-
cBeginDate
-
Usage: Retrieves the start date of the natural period N periods prior.
-
Parameters:
-
(Required) currentDate: The current date as a string in the format
yyyyMMdd. -
(Required) timeFormat: The type of natural period, with the following options:
-
w: Calendar week.
-
m: Calendar month.
-
q: Calendar quarter.
-
y: Calendar year.
-
-
(Optional) length: The number of natural periods to count back. If not provided, the default is 1.
-
(Required) format: The date format, which is
yyyyMMdd.
-
-
Return value:
-
The start date of the natural period N periods ago, returned as a string in the format
yyyyMMdd.
-
-
Example:
-
cBeginDate('20180118', 'm','yyyyMMdd')yields20171201. -
cBeginDate('20180118', 'w','yyyyMMdd')yields20180108. -
cBeginDate('20180118', 'w', 2,'yyyyMMdd')yields20180101.
-
cEndDate
-
Usage: Determines the end date of the previous natural period.
-
Parameters:
-
(Required) currentDate: The current date as a string in the format
yyyyMMdd. -
(Required) timeFormat: The type of natural period, with the following options:
-
w: Calendar week.
-
m: Calendar month.
-
q: Calendar quarter.
-
y: Calendar year.
-
-
(Required) format: The date format, which is
yyyyMMdd.
-
-
Return value:
-
The end date of the previous natural period, returned as a string in the format
yyyyMMdd.
-
-
Example:
-
cEndDate('20180118', 'm','yyyyMMdd')yields20171231. -
cEndDate('20180118', 'w','yyyyMMdd')yields20180114. -
cEndDate('20180118', 'y','yyyyMMdd')yields20171231.
-
tdBeginDate
-
Usage: Returns the start date of a natural period N periods back. Unlike cBeginDate, when length is omitted the default is the start of the current period, making this function well suited for up-to-today indicators.
-
Parameters:
-
(Required) currentDate: The current date as a string in the format
yyyyMMdd. -
(Optional) timeFormat: The type of natural period. If not provided, the default is 19700101. The allowed types are:
-
w: Calendar week.
-
m: Calendar month.
-
q: Calendar quarter.
-
y: Calendar year.
-
-
(Optional) length: The number of natural periods to count back. If not provided, the default is 0.
-
(Required) format: The date format, which is yyyyMMdd.
-
-
Return value:
-
The start date of the natural period N periods prior, returned as a string in the format
yyyyMMdd.
-
-
Example:
-
tdBeginDate('20180118','yyyyMMdd')yields19700101. -
tdBeginDate('20180118', 'm','yyyyMMdd')yields20180101. -
tdBeginDate('20180118', 'w','yyyyMMdd')yields20180115. -
tdBeginDate('20180118', 'w', 2,'yyyyMMdd')yields20180101.
-
CustomBeginDate
-
Usage: Returns the start date of a custom period N periods back, treating the current date as part of the first period. Use this function for statistical periods with non-standard boundaries, such as fiscal months and fiscal years. Often used with CustomEndDate.
-
Parameters:
-
(Required) currentDate: The current date as a string in the format
yyyyMMdd. -
(Required) timeFormat: The type of natural period, with the following options:
-
m: Calendar month.
-
q: Calendar quarter.
-
y: Calendar year.
-
-
(Required) customShift: The start date of the custom period, specified as a string. For year and quarter, the format is MMdd; for month, the default format is dd.
NoteNote: dd values only support numbers 01~28.
-
(Optional) length: The number of custom periods to count back. If not provided, the default is 1. If 0, it returns the start of the current period.
-
(Required) format: The date format, which is
yyyyMMdd.
-
-
Return value:
-
The start date of the custom period N periods prior, returned as a string in the format
yyyyMMdd.
-
-
Example:
-
CustomBeginDate('20190802', 'y', '0401','yyyyMMdd')yields20180401. -
CustomBeginDate('20190802', 'y', '0401', 0,'yyyyMMdd')yields20190401. -
CustomBeginDate('20190802', 'q', '0101','yyyyMMdd')yields20190401. -
CustomBeginDate('20190802', 'm', '15','yyyyMMdd')yields20190615. -
CustomBeginDate('20190802', 'm', '15', 2,'yyyyMMdd')yields20190515.
-
CustomEndDate
-
Usage: Returns the end date of a custom period N periods back, treating the current date as part of the first period. Use this function for statistical periods with non-standard boundaries, such as fiscal months and fiscal years. Often used with CustomBeginDate.
-
Parameters:
-
(Required) currentDate: The current date as a string in the format
yyyyMMdd. -
(Required) timeFormat: The type of natural period, with the following options:
-
m: Calendar month.
-
q: Calendar quarter.
-
y: Calendar year.
-
-
(Required) customShift: The start date of the custom period, specified as a string. For year and quarter, the format is
MMdd; for month, the default format is dd.NoteNote: dd values only support numbers 01~28.
-
(Optional) length: The number of custom periods to count back. If not provided, the default is 1.
-
(Required) format: The date format, which is
yyyyMMdd.
-
-
Return value:
-
The end date of the custom period N periods prior, returned as a string in the format
yyyyMMdd.
-
-
Example:
-
CustomEndDate('20190802', 'y', '0401','yyyyMMdd')yields20190331. -
CustomEndDate('20190802', 'q', '0101','yyyyMMdd')yields20190630. -
CustomEndDate('20190802', 'm', '15','yyyyMMdd')yields20190714. -
CustomEndDate('20190802', 'm', '15', 2,'yyyyMMdd')yields20190614.
-
substring
-
Usage: Returns a substring of the specified length starting from the given position. Positions begin at 1. A negative start value counts backward from the end of the string.
-
Parameters:
-
(Required) currentDate: The current date as a string in the format
yyyyMMdd. -
(Required) start: The start position for the substring.
-
(Required) len: The length of the substring to extract.
-
-
Return value:
-
Returns the substring of the specified length starting at the given start position from the string.
-
-
Example:
-
substring('20190802',1,4)yields2019. -
substring('20190802',1,6)yields201908.
-
lastNHour
-
Usage: Determines the start hour of the last N hours period.
-
Parameters:
-
(Required) currentDatetime: The business time as a string in the format
yyyyMMddHH0000. -
(Required) preHours: The number of hours to look back, specified as an integer.
-
-
Return value:
-
The start hour of the last N hours period, returned as a string in the format
yyyyMMddHH0000.
-
-
Example:
-
lastNHour('20180118160000', 7)yields20180118100000.
-
dthBeginDatetime
-
Usage: Returns the start of the day (00:00) for the given business time.
-
Parameters:
-
(Required) currentDatetime: The business time as a string in the format
yyyyMMddHH0000.
-
-
Return value:
-
The start of the day (00:00) for the given business time, returned as a string in the format
yyyyMMdd000000.
-
-
Example:
-
dthBeginDatetime('20180118160000')yields20180118000000.
-
lastNMinute
-
Usage: Determines the start minute of the last N minutes period.
-
Parameters:
-
(Required) currentDatetime: The business time as a string in the format
yyyyMMddHHmm00. -
(Required) preMinutes: The number of minutes to look back, specified as an integer.
-
-
Return value:
-
The start minute of the last N minutes period, returned as a string in the format
yyyyMMddHHmm00.
-
-
Example:
-
lastNMinutes('20180118164500', 45)yields20180118160000.
-
dtmiBeginDatetime
-
Usage: Returns the start of the day (00:00) for the given business time, or the start of the hour when timeFormat is set to
h. -
Parameters:
-
(Required) currentDatetime: The business time as a string, in the format
yyyyMMddHH0000. -
(Optional) timeFormat: The type of natural period, with the following option:
-
h: Hour.
-
-
-
Return value:
-
If the timeFormat parameter is
h, returns the start of the specified hour, in the formatyyyyMMddHH0000. -
If the timeFormat parameter is not provided, returns the start of the day (00:00), in the format
yyyyMMdd000000.
-
-
Example:
-
dtmiBeginDatetime('20180118160000')yields20180118000000. -
dtmiBeginDatetime('20180118164500', 'h')yields20180118160000.
-
Scenarios
|
Function |
Development/Modeling |
Quality/Partition filter expression |
|
lastNDate |
Supported |
Supported |
|
cBeginDate |
Supported |
Supported |
|
cEndDate |
Supported |
Supported |
|
tdBeginDate |
Supported |
Supported |
|
CustomBeginDate |
Supported |
Supported |
|
CustomEndDate |
Supported |
Supported |
|
substring |
Supported |
Not applicable |
|
lastNHour |
Supported |
Not applicable |
|
dthBeginDatetime |
Supported |
Not applicable |
|
lastNMinute |
Supported |
Not applicable |
|
dtmiBeginDatetime |
Supported |
Not applicable |
Application instances
|
Statistical period |
Start time expression |
End time expression |
|
Last day |
${bizdate} |
${bizdate} |
|
Last N days |
lastNDate('${bizdate}', N) |
${bizdate} |
|
Last M to N days |
lastNDate('${bizdate}', M) |
lastNDate('${bizdate}', N) |
|
Historical up to today |
tdBeginDate('${bizdate}') |
${bizdate} |
|
Calendar week |
cBeginDate('${bizdate}', 'w') |
cEndDate('${bizdate}', 'w') |
|
Calendar month |
cBeginDate('${bizdate}', 'm') |
cEndDate('${bizdate}', 'm') |
|
Calendar quarter |
cBeginDate('${bizdate}', 'q') |
cEndDate('${bizdate}', 'q') |
|
Calendar year |
cBeginDate('${bizdate}', 'y') |
cEndDate('${bizdate}', 'y') |
|
Last 2 calendar months |
cBeginDate('${bizdate}', 'm', 2) |
cEndDate('${bizdate}', 'm') |
|
Calendar week up to today |
tdBeginDate('${bizdate}', 'w') |
${bizdate} |
|
Calendar month up to today |
tdBeginDate('${bizdate}', 'm') |
${bizdate} |
|
Calendar quarter up to today |
tdBeginDate('${bizdate}', 'q') |
${bizdate} |
|
Calendar year up to today |
tdBeginDate('${bizdate}', 'y') |
${bizdate} |
|
Last calendar month up to today |
tdBeginDate('${bizdate}', 'm', 1) |
${bizdate} |
|
Fiscal year |
CustomBeginDate('${bizdate}', 'y', '0401') |
CustomEndDate('${bizdate}', 'y', '0401') |