ST_DateTime
Updated at:
Copy as MD
Returns the timestamp of a raster or a specific band.
Syntax
text ST_DateTime(raster raster_obj)
timestamp ST_DateTime(raster raster_obj, integer band)Parameters
| Parameter | Description |
|---|---|
raster_obj | The raster to query. |
band | The index of the band to query. Band indices start at 0. |
Description
The behavior depends on whether you pass the band parameter:
Without `band`: returns the timestamps of all bands as a JSON-formatted string (
text). Each key is a band index (starting at 0), and each value is the band's timestamp.With `band`: returns the timestamp of the specified band as a
timestampvalue.
Examples
Example 1 — All bands
Query the timestamps of all bands in a raster. The result is a JSON object mapping each band index to its timestamp.
SELECT ST_DateTime(raster_obj)
FROM raster_table;Result (truncated for readability — the full output includes all 24 bands):
st_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"}Example 2 — Single band
Query the timestamp of band 0.
SELECT ST_DateTime(raster_obj, 0)
FROM raster_table;Result:
datetime
---------------------------
"Mon Dec 31 00:00:00 2018"Is this page helpful?