Retrieve Dates and Times

You retrieve dates and times from the database in these ways.

  • Using any interface, as a string

  • Using ODBC, as a TIMESTAMP structure

  • Using embedded SQL, as a SQLDATETIME structure

Usage

When a date or time is retrieved as a string, it is retrieved in the format specified by the database options DATE_FORMAT, TIME_FORMAT and TIMESTAMP_FORMAT.

The following operators are allowed on dates:

Operators

Operator

Description

timestamp + integer

Add the specified number of days to a date or timestamp.

timestamp - integer

Subtract the specified number of days from a date or timestamp.

date - date

Compute the number of days between two dates or timestamps.

date + time

Create a timestamp combining the given date and time.

Related reference
TIMESTAMP Special Value
CURRENT TIMESTAMP Special Value
CURRENT TIME Special Value
CURRENT DATE Special Value
Date and Time Data Types