TO_DSINTERVAL string_value Formats - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905
  • SQL Interval Format

    The format for an interval day to second is [+ | -]DD HH:MM:SS[.xxxxxx]. One or more spaces separate the day from hour element. There can be any number of spaces between elements. DD is an integer between 0 and 9999, HH is an integer between 0 and 23, MM is an integer between 0 and 59, and SS is an integer between 0 and 59. The optional fractional seconds can be from .0 to .999999.

  • ISO Duration Format

    The format for a duration is [-]P[n]DT[n]H[n]M[n][.frac_secs]S where n specifies the value of the element (for example, 4H is 4 hours). This represents a subset of the ISO duration format and any other duration letters (including valid ISO letters such as Y and M) cause an error.

    Leading and trailing zeros are optional. Spaces are not allowed within the element format. Elements with the value zero may be omitted, but at least one element and its number is required.

    A leading negative sign is used to denote a negative interval. If omitted, the interval is positive. A positive sign is not allowed. Element values are integers between 0 and any value that does not cause an interval overflow. Fractional seconds are optional and can be between .0 and .999999.

    The T designator precedes the time elements (and removes the ambiguity of M between months and minutes within the full ISO duration syntax). If there are no H, M, or S time elements, T is omitted.

    Values can exceed their normal time limit. For example, PT72H represents 72 hours even though there are 24 hours in a day. The ISO duration letter designators have the following meaning (only the P, D, T, H, M, and S designators are allowed for the DAY to SECONDS interval):

    ISO Designator Definition
    P Duration. At the beginning.
    D Day. Follows the number of days.
    T Time. Precedes the time elements H, M, and S.
    H Hour. Follows the number of hours.
    M Minutes. Follows the number of minutes.
    S Second. Follows the number of seconds.

    You can also pass arguments with data types that can be converted to the preceding types using the implicit data type conversion rules that apply to UDFs.

The UDF implicit type conversion rules are more restrictive than the implicit type conversion rules typically used by Vantage. An argument that cannot be converted to the required data type following the UDF implicit conversion rules must be explicitly cast.