从Postgres中的纪元列表中获取特定时间段



我在Postgres中有下表,其中包含纪元时间戳。我想选择太平洋标准时间中时间从 20:00 到 21:00的时间戳。我已经部分尝试了以下内容,但我似乎无法同时提取小时和分钟。

SELECT timestamp from table where extract(‘hour’ from to_timestamp(created_at) at time zone ‘America/Los_angeles’) > 20

|created_at|

|1526528788 |

|1526442388 |

|1526309188 |

|1526359588 |

|1526532388 |

|1526489188 |

预期成果:

|created_at|

|1526528788 |

|1526442388 |

任何帮助将不胜感激。

当你的意思是PST时,你为什么要写America/Los Angeles?它们(有时(是不同的。

这能解决您的问题吗:

... WHERE extract(hour FROM
to_timestamp(1526309188) AT TIME ZONE 'PST'
) BETWEEN 20 AND 21;

最新更新