OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.2.5

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & CertificationTicket
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.2.5
    iconOceanBase Database
    SQL - V 4.2.5
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    SQL
    KV
    • V 4.6.0
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    INTERVAL DAY TO SECOND data type

    Last Updated:2026-04-09 09:38:52  Updated
    Share
    What is on this page
    Syntax
    Parameters
    Considerations
    Calculation of intervals and other date types
    Examples

    folded

    Share

    The INTERVAL DAY TO SECOND data type stores periods in days, hours, minutes, and seconds. This data type can represent the precise difference between two datetime values. This topic describes the syntax, parameters, and considerations of the INTERVAL DAY TO SECOND data type.

    Syntax

    INTERVAL DAY [(precision)] TO SECOND [(fractional_seconds_precision)]
    

    Parameters

    Parameter
    Value range
    Description
    precision [0,9] The precision of the DAY element. Default value: 2.
    fractional_seconds_precision [0,9] The precision of the fractional seconds of the SECOND element. Default value: 6, which indicates that the value is accurate to microseconds.

    Considerations

    The following table lists supported formats that you can use when you insert values of the INTERVAL DAY TO SECOND data type. For more information about how to specify values of interval data types, see Interval literals.

    Syntax
    Example
    Description
    INTERVAL 'dd hh:mm:ss' DAY(precision) TO SECOND(fractional_seconds_precision) INTERVAL '140 5:12:10.2222222' DAY(3) TO SECOND(7) Indicates an interval of 140 days, 5 hours, 12 minutes, and 10.2222222 seconds.
    INTERVAL 'dd hh'DAY(precision) TO HOUR INTERVAL '400 5' DAY(3) TO HOUR Indicates an interval of 400 days and 5 hours.
    INTERVAL 'dd hh:mm'DAY(precision) TO MINUTE INTERVAL '4 5:12' DAY TO MINUTE Indicates an interval of 4 days, 5 hours, and 12 minutes.
    INTERVAL 'hh:mm' HOUR TO MINUTE INTERVAL '11:20' HOUR TO MINUTE Indicates an interval of 11 hours and 20 minutes.
    INTERVAL 'hh:mm:ss' HOUR TO SECOND(fractional_seconds_precision) INTERVAL '11:12:10.2222222' HOUR TO SECOND(7) Indicates an interval of 11 hours, 12 minutes, and 10.2222222 seconds.
    INTERVAL 'dd' DAY(precision) INTERVAL '14' DAY Indicates an interval of 14 days.
    INTERVAL 'hh' HOUR INTERVAL '160' HOUR Indicates an interval of 160 hours.
    INTERVAL 'mm' MINUTE INTERVAL '14' MINUTE Indicates an interval of 14 minutes.
    INTERVAL 'ss' SECOND(fractional_seconds_precision) INTERVAL '14.666' SECOND(2, 3) Indicates an interval of 14.666 seconds.

    Calculation of intervals and other date types

    OceanBase Database supports conversion between data types. Therefore, you can perform mathematical operations on interval values and other date values. However, OceanBase Database does not support any addition, subtraction, multiplication, and division operation on values of different data types.

    For more information about the calculation matrix and conversion of the supported data types, see Calculation of dates, timestamps, and intervals and Data type conversion rules.

    For more information about the calculation of intervals and other data types, see INTERVAL YEAR TO MONTH data type.

    Examples

    Create two columns interval1 and interval2 of the INTERVAL DAY TO SECOND data type in the Interval_Sample table and insert values into the two columns.

    CREATE TABLE Interval_Sample (interval1 INTERVAL DAY TO SECOND, interval2 INTERVAL DAY(3) TO SECOND(3));
    INSERT INTO Interval_Sample (interval1, interval2) VALUES ( INTERVAL '15 06:10:08' DAY TO SECOND, INTERVAL '150 06:10:08' DAY(3) TO SECOND(3));
    
    obclient> SELECT * FROM Interval_Sample;
    +---------------------+-------------------+
    | INTERVAL1           | INTERVAL2         |
    +---------------------+-------------------+
    | +15 06:10:08.000000 | +150 06:10:08.000 |
    +---------------------+-------------------+
    1 row in set
    

    Previous topic

    INTERVAL YEAR TO MONTH data type
    Last

    Next topic

    Calculation of dates, timestamps, and intervals
    Next
    What is on this page
    Syntax
    Parameters
    Considerations
    Calculation of intervals and other date types
    Examples