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

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogWhite PaperLive 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.3.1
    iconOceanBase Database
    SQL - V 4.3.1
    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

    Datetime values

    Last Updated:2026-04-15 08:25:15  Updated
    Share
    What is on this page
    DATE values
    DATETIME and TIMESTAMP values
    TIME values

    folded

    Share

    OceanBase Database supports datetime literals in string and number formats.

    Differences between strings and numbers:

    • A string can contain all delimiters, such as '2015-07-21 12:34:56.789', or no delimiters, such as '20150721'.

    • A number can use only a decimal point (.) as the delimiter between seconds and microseconds, such as 20150721123456.789.

    When you need to use delimiters in other scenarios, we recommend that you use only dashes (-), forward slashes (/), and colons (:).

    DATE values

    OceanBase Database recognizes a DATE value in one of the following formats:

    • 'YYYY-MM-DD' or 'YY-MM-DD'. Any punctuation characters can be used as delimiters between date parts. For example, '2012-12-31', '2012/12/31', '2012^12^31', and '2012@12@31' are equivalent.

    • 'YYYYMMDD' or 'YYMMDD', provided that the string is a meaningful date value. For example, '20070523' or '070523' can be parsed as '2007-05-23', but '071532' is invalid and returns NULL because it contains meaningless month and day parts.

    • 'YYYYMMDD' or 'YYMMDD', provided that the number is a meaningful date value. For example, 19830905 or 830905 can be parsed as "1983-09-05".

      Notice

      If sql_mode contains STRICT_TRANS_TABLES or NO_ZERO_IN_DATE, and the month or day part of a date contains 0, an error is returned, except for '0000-00-00'.

    DATETIME and TIMESTAMP values

    OceanBase Database recognizes a DATETIME or TIMESTAMP value in the following formats:

    • 'YYYY-MM-DD hh:mm:ss' or 'YY-MM-DD hh:mm:ss'. Any punctuation characters can be used as delimiters between date or time parts. For example, '2012-12-31 11:30:45', '2012^12^31 11+30+45', '2012/12/31 11*30*45', and '2012@12@31 11^30^45' are equivalent.

      Note that the decimal point is the only delimiter that is recognizable between a date and time part and a fractional part of seconds. The date and time parts can be separated either by a letter T or a space. For example, '2012-12-31 11:30:45' and '2012-12-31T11:30:45' are equivalent.

    • 'YYYYMMDDhhmmss' or 'YYMMDDhhmmss', provided that the string is a meaningful date value. For example, '20070523091528' or '070523091528' can be parsed as '2007-05-23 09:15:28', but '071122129015' is invalid and returns NULL because it contains a meaningless minute part.

    • YYYYMMDDhhmmss or YYMMDDhhmmss, provided that the string is a meaningful date value. For example, 19830905132800 and 830905132800 can be parsed as '1983-09-05 13:28:00'.

    A DATETIME or TIMESTAMP value can include a trailing fractional seconds part of at most 6 digits to achieve a precision of up to microseconds. The fractional part can be separated from other time parts only with a decimal point. Other fractional part delimiters are unrecognizable.

    OceanBase Database uses the following rules to parse a date that contains a two-digit year value:

    • A year value in the range of 70-99 becomes 1970-1999.

    • A year value in the range of 00-69 becomes 2000-2069.

    You do not need to specify two digits for a month or day value that is less than 10. For example, '2015-6-9' is equivalent to '2015-06-09'. Likewise, you do not need to specify two digits for an hour, minute, or second value that is smaller than 10. For example, '2015-10-30 1:2:3' is equivalent to '2015-10-30 01:02:03'.

    In addition, OceanBase Database selects a format based on the value length:

    • YYMMDD for a 6-digit value

    • YYYYMMDD for an 8-digit value

    • YYMMDDHHMMSS for a 12-digit value

    • YYYYMMDDHHMMSS for a 14-digit value

    TIME values

    OceanBase Database recognizes a TIME value in one of the following formats:

    • 'D hh:mm:ss', or any of the following: 'hh:mm:ss', 'hh:mm', 'D hh:mm', 'D hh', and 'ss'. D represents the number of days, and the valid values are an integer from 0 to 34.

    • 'hhmmss' without delimiters, provided that the number is a meaningful date value. For example, '101112' can be parsed as '10:11:12', but '109712' is invalid and becomes '00:00:00' because it contains a meaningless minute part.

    • hhmmss, or any of the following: ss, mmss, and hhmmss, provided that the number is a meaningful date value. For example, 101112 can be parsed as '10:11:12'.

    A trailing fractional seconds part is recognized in the following formats: 'D hh:mm:ss.fraction', 'hh:mm:ss.fraction', 'hhmmss.fraction', and hhmmss.fraction. The fractional part can contain at most 6 digits to achieve a precision of up to microseconds. The fractional part can be separated from other time parts only with a decimal point. Other fractional part delimiters are unrecognizable.

    Previous topic

    Numbers
    Last

    Next topic

    Bit values
    Next
    What is on this page
    DATE values
    DATETIME and TIMESTAMP values
    TIME values