Print      Open PDF Version of Online Help


Previous Topic

Next Topic

Duration

The Duration function in Expression Builder returns a number that indicates a period in days or fractions of days as indicated by the period argument.

Syntax

Duration(period)

Result Type

Number

Arguments

The following table describes the arguments for the function.

Argument

Description

period

Specifies the period that is to be returned. The value can be a string literal in the format PnYnMnDTnHnM, or an expression that evaluates to a string in the format PnYnMnDTnHnM.

In the PnYnMnDTnHnM string:

  • P is the period indicator
  • nY specifies the number of years
  • nM specifies the number of months
  • nD specifies the number of days
  • T separates the date and time specifications
  • nH specifies the number of hours
  • nM specifies the number of minutes

For example, assume that you want to specify a period of 50 months. You can specify the period as a string literal, for example, as P4Y2M, or as P50M. Alternatively, if you want to specify a period that varies depending on a value in a field, then you can use that field in an expression in the argument.

In the following example, Deferral Period is a custom field that is set up to store a value for a period in months. The value in the Deferral Period field is used to calculate the period:

Duration('P'+ FieldValue([{nDeferral_Period}])+'M')

So, if the value in the Deferral Period field is 12, then the expression evaluates to P12M, which is a valid string for the argument. If the value in the Deferral Period field is 50, then the expression evaluates to P50M, which is also a valid string.

You can specify any number of years, months, days, hours, or minutes in the string literal. Similarly, if the argument contains an expression, there is no limit on the number that can be returned by the expression.

The following considerations apply to the period argument:

  • Do not specify a plus sign (+) for positive values.
  • You can specify a negative duration as -Duration(period) or Duration(-period).
  • Specifying seconds is not supported.
  • If the number of years, months, days, hours, or minutes is zero, you can omit the number and its corresponding designator.
  • If none of the time components are present in the period, the T designator must not be included in the period.
  • The designator P must always be present in the period.

Examples

The following are valid examples of the Duration function:

Duration('P0Y1M1DT2H5M')

Duration('P0Y0DT1H')

Duration('P1D')

Duration('P0Y0M0DT0H0M')

Duration('P0DT1M')

Duration('P24M')

Duration('P500D')

Duration('P'+ FieldValue([{nDeferral_Period}])+'M')

Duration(‘PT1000H3M’)

Duration(‘-P1Y200M’)

Related Topics

See the following topics for related Expression Builder information:


Published 6/21/2021 Copyright © 2005, 2021, Oracle and/or its affiliates. Legal Notices.