SQL 获取时间字段的小时时间方法
在 SQL 中,可以使用函数 EXTRACT 和 DATE_PART 来获取时间字段的小时时间。
使用 EXTRACT 函数:
SELECT EXTRACT(hour FROM my_time_field) AS hour FROM my_table;
其中,'my_time_field' 是指时间字段名称,'my_table' 是指表名称。
使用 DATE_PART 函数:
SELECT DATE_PART('hour', my_time_field) AS hour FROM my_table;
其中,'hour' 是指需要提取的时间单位,'my_time_field' 是指时间字段名称,'my_table' 是指表名称。
原文地址: https://www.cveoy.top/t/topic/mBuQ 著作权归作者所有。请勿转载和采集!