OceanBase logo

OceanBase

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

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

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

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.3.0

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & Certification
    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.3.0
    iconOceanBase Database
    SQL - V 4.3.0
    SQL
    KV
    • 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

    DATE, DATETIME, and TIMESTAMP types

    Last Updated:2026-04-15 08:30:01  Updated
    share
    What is on this page
    DATE
    DATETIME
    TIMESTAMP

    folded

    share

    DATE, DATETIME and TIMESTAMP types are related to each other. This topic describes their features, similarities, and differences.

    DATE

    The DATE type is used to represent a value that has only the date part.

    A DATE value is searched and displayed in the 'YYYY-MM-DD' format in the range of '0000-00-00' to '9999-12-31'.

    OceanBase Database allows you to assign string or numeric values to a DATE column.

    The syntax is as follows:

    DATE
    

    DATETIME

    The DATETIME type is used to represent a value that contains both date and time parts.

    A DATETIME value is searched and displayed in the 'YYYY-MM-DD hh:mm:ss' format in the range of '0000-00-00 00:00:00' to '9999-12-31 23:59:59'.

    The syntax is as follows:

    DATETIME[(fsp)]
    

    The optional parameter fsp specifies the precision of the fractional part. The value range is [0,6]. The value 0 indicates that the time value does not have the fractional part. If you omit this parameter, the default value 0 is used.

    You can use the DEFAULT and ON UPDATE clauses to specify the automatic initialization and update of the date and time values in the DATETIME column.

    A DATETIME value can be displayed in the 'YYYY-MM-DD hh:mm:ss[.fraction]' format where the fractional part can contain up to six decimal places, which means the time can be accurate to microseconds. The value ranges from '0000-00-00 00:00:00.000000' to '9999-12-31 23:59:59.999999'. The fractional part is separated from other digits with a decimal point. Other separators are not recognized.

    TIMESTAMP

    The TIMESTAMP type is used to represent a value that contains both date and time parts.

    The syntax is as follows:

    TIMESTAMP[(fsp)]
    

    The optional parameter fsp specifies the precision of the fractional part. The value range is [0,6]. The value 0 indicates that the time value does not have the fractional part. If you omit this parameter, the default value 0 is used.

    Here is an example:

    CREATE TABLE t(C1 TIMESTAMP(6));
    

    You can use the DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP clauses to specify the automatic initialization and update of the date and time values in the TIMESTAMP column. By default, the first TIMESTAMP column has such attributes. You can also specify these attributes for other TIMESTAMP columns in the table.

    A TIMESTAMP value can be displayed in the 'YYYY-MM-DD hh:mm:ss[.fraction]' format where the fractional part can contain up to six decimal places, which means the time can be accurate to microseconds. The value ranges from '0000-00-00 00:00:00.000000' to '9999-12-31 23:59:59.999999'. The fractional part is separated from other digits with a decimal point. Other separators are not recognized.

    OceanBase Database converts a TIMESTAMP value from the local time into the UTC time for storage and converts the UTC time back into the local time for retrieval. By default, the time zone on the server is used as the current time zone for each connection. However, you can also change the time zone for each connection. If you use different time zones during the two-way time conversion, the value retrieved after the time zone change may be different from the stored value. As long as the time zones remain unchanged, the stored values can be retrieved. The current time zone can be the value of the time_zone variable.

    Previous topic

    Overview
    Last

    Next topic

    TIME type
    Next
    What is on this page
    DATE
    DATETIME
    TIMESTAMP