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);| Signature | Returns | When to use |
|---|---|---|
ST_DateTime(raster_obj) | text — JSON-formatted string | Retrieve datetime for all bands at once |
ST_DateTime(raster_obj, band) | timestamp | Retrieve datetime for one specific band |
Parameters
| Parameter | Type | Description |
|---|---|---|
raster_obj | raster | The raster object to query. |
band | integer | The 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 singletimestampfor 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
ST_MetaData — returns spatial and pixel metadata for a raster
ST_NumBands — returns the number of bands in a raster
ST_BandMetaData — returns metadata for a specific band