timestamp
我用一列来指示一行是在白天还是晚上创建的。我的代码如下,但由于某种原因,我只得到“DAY”作为结果。我没有正确格式化值吗?
select record_id, rec_date,
case when date_part('hour', rec_date) between 20 and 07 then 'Night'
else 'Day' end as Indicator
from records;
Run Code Online (Sandbox Code Playgroud)
该rec_date
列是一个时间戳,我可以在其中看到诸如2019-11-20 21:34:02.000000
- 之类的值,它应该得到一个'Night'
指标。