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 Call Interface

V2.0.1Enterprise Edition

  • What's New
  • Product Introduction
  • Install OBCI
  • Data Types
  • Reference Functions
    • Connect, authorize, and initialize functions
    • Handle and descriptor functions
    • Bind, define, and describe functions
    • Statement functions
    • LoB functions
    • Transaction functions
    • Miscellaneous functions
    • String functions
    • Date functions
    • Number functions
  • Developer Guide
    • Basic development procedure
    • Development example

Download PDF

What's New Product Introduction Install OBCI Data Types Connect, authorize, and initialize functionsHandle and descriptor functionsBind, define, and describe functionsStatement functionsLoB functionsTransaction functionsMiscellaneous functionsString functionsDate functionsNumber functionsBasic development procedureDevelopment example
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 Call Interface
  3. V2.0.1
iconOceanBase Call Interface
V 2.0.1Enterprise Edition
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

Date functions

Last Updated:2023-06-29 06:42:04  Updated
Share
What is on this page
OCIDateSysDate
OCIDateToText
OCIDateFromText
OCIDateTimeToText
OCIDateTimeFromText
OCIDateTimeConstruct
OCIDateTimeGetTime
OCIDateTimeGetDate
OCIDateTimeGetTimeZoneOffset

folded

Share

#docslug#/obci/obci/V2.0.1/ds6ff5

OCIDateSysDate

Description : You can call this function to get the current system date and time of the client.

Function prototype :

sword OCIDateSysDate ( 
OCIError       *err,
OCIDate        *sys_date );

Parameters :

Parameter
Description
err(IN/OUT) An error handle.
sys_date(OUT) The current system date and time of the client.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCIDateToText

Description : You can call this function to convert a date type to a character string.

Function prototype :

sword OCIDateToText ( 
OCIError                  *err, 
const OCIDate             *date,
const OraText             *fmt,
ub1                       fmt_length,
const OraText             *lang_name,
ub4                       lang_length,
ub4                       *buf_size,
OraText                   *buf );

Parameters :

Parameter
Description
err(IN/OUT) An error handle.
date(IN) The date to be converted.
fmt(IN) The conversion format. If it is NULL and (text *) 0, the date is converted to a string in the default date format, which is DD-MON-YY.
fmt_length(IN) The length of the fmt parameter.
lang_name(IN) Specifies the language in which names and abbreviations for months and days are returned. The default language of the session is used if lang_name is NULL ((text *) 0).
lang_length(IN) The length of the lang_name parameter.
buf_size(IN/OUT) The size of the buffer (IN). The size of the resulting string is returned by using this parameter (OUT).
buf(OUT) The buffer where the converted string is placed.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCIDateFromText

Description : You can call this function to convert a string to a date type in the specified format.

Function prototype :

sword OCIDateFromText ( 
OCIError           *err,
const OraText      *date_str,
ub4                d_str_length,
const OraText      *fmt,
ub1                fmt_length,
const OraText      *lang_name,
ub4                lang_length,
OCIDate            *date );

Parameters :

Parameter
Description
err(IN/OUT) An error handle.
date_str(IN) The date to be converted.
d_str_length(IN) The size of the input string. The date_str parameter is considered as a string that ends with NULL if the length is -1.
fmt(IN) The conversion format. If fmt is a NULL pointer, the string must be in DD-MON-YY format.
fmt_length(IN) The length of the fmt parameter.
lang_name(IN) Specifies the language in which names and abbreviations for months and days are returned. The default language of the session is used if lang_name is NULL.
lang_length(IN) The length of the lang_name parameter.
date(OUT) The given string that is converted to date.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCIDateTimeToText

Description : You can call this function to convert a given date to a string in the specified format.

Function prototype :

sword OCIDateTimeToText ( 
void                *hndl,
OCIError            *err,
const OCIDateTime   *date,
const OraText       *fmt,
ub1                 fmt_length,
ub1                 fsprec,
const OraText       *lang_name,
size_t              lang_length,
ub4                 *buf_size,
OraText             *buf );

Parameters :

Parameter
Description
hndl(IN) An OCI user session handle or environment handle. If the user session handle is passed in, the conversion takes place in NLS_LANGUAGE and NLS_CALENDAR of the session. Otherwise, the default value is used.
err(IN/OUT) An error handle.
date(IN) The date to be converted.
fmt(IN) The conversion format. If fmt is a NULL pointer, the result must be in the default format of the DATETIME type.
fmt_length(IN) The length of the fmt parameter.
fsprec(IN) Specifies the fractional second precision.
lang_name(IN) Specifies the language in which names and abbreviations for months and days are returned. The default language of the session is used if lang_name is NULL.
lang_length(IN) The length of the lang_name parameter.
buf_size(IN/OUT) The size of the buffer (IN). The size of the converted string (the result of the conversion) is returned (OUT).
buf(OUT) The buffer where the converted string is placed.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCIDateTimeFromText

Description : You can call this function to convert a given string to the datetime type in the specified format.

Function prototype :

sword OCIDateTimeFromText ( 
void               *hndl,
OCIError           *err,
const OraText      *date_str,
size_t             dstr_length,
const OraText      *fmt,
ub1                fmt_length,
const OraText      *lang_name,
size_t             lang_length,
OCIDateTime        *datetime );

Parameters :

Parameter
Description
hndl(IN) An OCI user session handle or environment handle. If the user session handle is passed in, the conversion takes place in NLS_LANGUAGE and NLS_CALENDAR of the session. Otherwise, the default value is used.
err(IN/OUT) An error handle.
date_str(IN) The input string to be converted to Oracle datetime.
dstr_length(IN) The size of the input string. The date_str parameter is considered as a string that ends with NULL if the length is -1.
fmt(IN) The conversion format. If fmt is a NULL pointer, the result must be in the default format of the DATETIME type.
fmt_length(IN) The length of the fmt parameter.
lang_name(IN) Specifies the language in which names and abbreviations for months and days are returned. The default language of the session is used if lang_name is NULL.
lang_length(IN) The length of the lang_name parameter.
datetime(OUT) The given string that needs to be converted to date.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCIDateTimeConstruct

Description : You can call this function to construct a datetime descriptor.

Function prototype :

sword OCIDateTimeConstruct ( 
void          *hndl,
OCIError      *err,
OCIDateTime   *datetime,
sb2           year,
ub1           month,
ub1           day,
ub1           hour,
ub1           min,
ub1           sec,
ub4           fsec,
OraText       *timezone,
size_t        timezone_length );

Parameters :

Parameter
Description
hndl(IN) An OCI user session handle or environment handle. If the user session handle is passed in, the conversion takes place in NLS_LANGUAGE and NLS_CALENDAR of the session. Otherwise, the default value is used.
err(IN/OUT) An error handle.
datetime(IN) The pointer to an OCIDateTime descriptor.
year(IN) The value for year.
month(IN) The value for month.
day(IN) The value for day.
hour(IN) The value for hour.
min(IN) The value for minute.
sec(IN) The value for second.
fsec(IN) The value for fractional second.
timezone(IN) Time zone string. The time zone offset of a particular time zone from GMT in the format of [[+|-][HH:MM]. For example: -08:00.
timezone_length(IN) The length of the time zone string.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCIDateTimeGetTime

Description : You can call this function to fetch the time (including the values for hour, minute, second, and fractional second) out of a datetime value.

Function prototype :

void OCIDateTimeGetTime ( 
void          *hndl,
OCIError      *err,
OCIDateTime   *datetime,
ub1           *hour,
ub1           *min,
ub1           *sec,
ub4           *fsec );

Parameters :

Parameter
Description
hndl(IN) An OCI user session handle or environment handle. If the user session handle is passed in, the conversion takes place in NLS_LANGUAGE and NLS_CALENDAR of the session. Otherwise, the default value is used.
err(IN/OUT) An error handle.
datetime(IN) The pointer to an OCIDateTime descriptor.
hour(OUT) The value for hour.
min(OUT) The value for minute.
sec(OUT) The value for second.
fsec(OUT) The value for fractional second.

Return value : NULL.

OCIDateTimeGetDate

Description : You can call this function to fetch the date (including values for the year, month, and the day) out of a datetime value.

Function prototype :

void OCIDateTimeGetDate ( 
void               *hndl,
OCIError           *err,
const OCIDateTime  *datetime,
sb2                *year,
ub1                *month,
ub1                *day );

Parameters :

Parameter
Description
hndl(IN) An OCI user session handle or environment handle. If the user session handle is passed in, the conversion takes place in NLS_LANGUAGE and NLS_CALENDAR of the session. Otherwise, the default value is used.
err(IN/OUT) An error handle.
datetime(IN) The pointer to an OCIDateTime descriptor.
year(OUT) The value for year.
month(OUT) The value for month.
day(OUT) The value for day.

Return value : NULL.

OCIDateTimeGetTimeZoneOffset

Description : You can call this function to fetch the time zone offset (including the values for hour and minute) out of a datetime value.

Function prototype :

void OCIDateTimeGetTimeZoneOffset ( 
void               *hndl,
OCIError           *err,
const OCIDateTime  *datetime,
sb1                *hour,
sb1                *min);

Parameters :

Parameter
Description
hndl(IN) An OCI user session handle or environment handle. If the user session handle is passed in, the conversion takes place in NLS_LANGUAGE and NLS_CALENDAR of the session. Otherwise, the default value is used.
err(IN/OUT) An error handle.
datetime(IN) The pointer to an OCIDateTime descriptor.
hour(OUT) The retrieved hour value in a time zone.
min(OUT) The retrieved minute value in a time zone

Return value : NULL.

Previous topic

String functions
Last

Next topic

Number functions
Next
What is on this page
OCIDateSysDate
OCIDateToText
OCIDateFromText
OCIDateTimeToText
OCIDateTimeFromText
OCIDateTimeConstruct
OCIDateTimeGetTime
OCIDateTimeGetDate
OCIDateTimeGetTimeZoneOffset