All Products
Search
Document Center

PolarDB:ST_DateTime

Last Updated:Mar 28, 2026

Retrieves the datetime metadata of a raster object or a specific band.

Syntax

-- Return datetime for all bands
text ST_DateTime(raster raster_obj);

-- Return datetime for a specific band
timestamp ST_DateTime(raster raster_obj, integer band);
SignatureReturnsWhen to use
ST_DateTime(raster_obj)text — JSON-formatted stringRetrieve datetime for all bands at once
ST_DateTime(raster_obj, band)timestampRetrieve datetime for one specific band

Parameters

ParameterTypeDescription
raster_objrasterThe raster object to query.
bandintegerThe sequence number of the band. Valid values start from 0.

Description

  • Without band: returns a JSON-formatted string where each key is a band sequence number (zero-indexed) and each value is the corresponding datetime.

  • With band: returns a single timestamp for the specified band.

Note: The band parameter is zero-indexed. Band 0 is the first band, band 1 is the second, and so on.

Examples

Get datetime for all bands

SELECT ST_DateTime(raster_obj)
FROM raster_table;

Result: a JSON string mapping each band index to its datetime.

{"0":"Mon Dec 31 00:00:00 2018","1":"Mon Dec 31 01:00:00 2018","2":"Mon Dec 31 02:00:00 2018",...,"23":"Mon Dec 31 23:00:00 2018"}

Get datetime for a specific band

SELECT ST_DateTime(raster_obj, 0)
FROM raster_table;

Result:

"Mon Dec 31 00:00:00 2018"

See also