Teradata Package for Python Function Reference on VantageCloud Lake - make_interval - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.

Teradata® Package for Python Function Reference on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Package for Python
Release Number
20.00.00.11
Publication Date
August 2026
Content Type
Programming Reference
Publication ID
B700-4500-200K
ft:locale
en-US
ft:lastEdition
2026-08-13
ft:sourceId
FTML
dita:id
TeradataPython_FxRef_Lake_2000
Product Category
Teradata Vantage
teradataml.dataframe.functions.make_interval = make_interval(years=None, months=None, weeks=None, days=None, hours=None, minutes=None, seconds=None)
DESCRIPTION:
    Returns the interval based on the provided fields.
 
    Notes:
        * Combinations of year and month fields with day and time fields are not supported.
        * At least one argument must be provided in order to create interval type.
 
PARAMETERS:
    years:
        Optional Argument.
        Specifies number of years.
        Types: int, float, ColumnExpression
 
    months:
        Optional Argument.
        Specifies number of months.
        Types: int, float, ColumnExpression
 
    weeks:
        Optional Argument.
        Specifies number of weeks.
        Types: int, float, ColumnExpression
 
    days:
        Optional Argument.
        Specifies number of days.
        Types: int, float, ColumnExpression
 
    hours:
        Optional Argument.
        Specifies number of hours.
        Types: int, float, ColumnExpression
 
    minutes:
        Optional Argument.
        Specifies number of minutes.
        Types: int, float, ColumnExpression
 
    seconds:
        Optional Argument.
        Specifies number of seconds (fractional seconds allowed).
        Types: int, float, ColumnExpression
 
RETURNS:
    ColumnExpression
 
RAISES:
    TeradataMlException
 
EXAMPLES:
    # Load the data to run the example.
    >>> load_example_data("teradataml", "make_interval_data")
    
    # Create a DataFrame on 'make_interval_data' table.
    >>> df = DataFrame("make_interval_data")
    >>> df
           months  weeks  days  hours  minutes  seconds
    years                                              
    5           0      0     0      0        0    0.000
    1           2      0    10      5       30   20.500
    0           0      0     7     23       59   59.999
    0           6      2     0     12        0    0.000
 
 
    # Example 1: Create YEAR TO MONTH interval with the values provided in 'years' and 'months' columns.
    >>> from teradataml.dataframe.functions import make_interval
    >>> res = df.assign(iv_ym = make_interval(years=df.year, months=df.month))
    >>> res
           months  weeks  days  hours  minutes  seconds     iv_ym
    years                                                        
    0           6      2     0     12        0    0.000      0-06
    0           0      0     7     23       59   59.999      0-00
    1           2      0    10      5       30   20.500      1-02
    5           0      0     0      0        0    0.000      5-00
 
    >>> res.tdtypes
    years                     INTEGER()
    months                    INTEGER()
    weeks                     INTEGER()
    days                      INTEGER()
    hours                     INTEGER()
    minutes                   INTEGER()
    seconds                     FLOAT()
    iv_ym      INTERVAL_YEAR_TO_MONTH()
 
    # Example 2: Creating YEAR interval with a constant value.
    >>> res = df.assign(iv_year = make_interval(years=2))
    >>> res
           months  weeks  days  hours  minutes  seconds   iv_year
    years                                                        
    5           0      0     0      0        0    0.000      2-00
    1           2      0    10      5       30   20.500      2-00
    0           0      0     7     23       59   59.999      2-00
    0           6      2     0     12        0    0.000      2-00
 
    >>> res.tdtypes
    years            INTEGER()
    months           INTEGER()
    weeks            INTEGER()
    days             INTEGER()
    hours            INTEGER()
    minutes          INTEGER()
    seconds            FLOAT()
    iv_year    INTERVAL_YEAR()
 
    # Example 4: Create DAY TO SECOND interval with the values provided in 'weeks', 'days', 
    #            'hours', 'minutes' and 'seconds' columns.
    >>> res = df.assign(iv_d2s = make_interval(weeks=df.weeks, days=df.days, hours=df.hours,
    ...                 minutes=df.minutes, seconds=df.seconds))
    >>> res
           months  weeks  days  hours  minutes  seconds                 iv_d2s
    years                                                                     
    5           0      0     0      0        0    0.000      0 00:00:00.000000
    1           2      0    10      5       30   20.500     10 05:30:20.500000
    0           0      0     7     23       59   59.999      7 23:59:59.999000
    0           6      2     0     12        0    0.000     14 12:00:00.000000
 
    >>> res.tdtypes
    years                     INTEGER()
    months                    INTEGER()
    weeks                     INTEGER()
    days                      INTEGER()
    hours                     INTEGER()
    minutes                   INTEGER()
    seconds                     FLOAT()
    iv_d2s     INTERVAL_DAY_TO_SECOND()