我有一个带有这个日期时间戳的数据表 DATETIME25.6 格式如下: 04JAN2011:05:00:00:000000 如何选择一系列记录,例如 January 4, 2011 以及 January 20, 2011 ?
DATETIME25.6
04JAN2011:05:00:00:000000
January 4, 2011
January 20, 2011
ibrsph3r1#
将日期转换为可比较格式( 'yyyy-MM-dd' )使用 from_unixtime(unix_timestamp(date, from_format), to_format) :
'yyyy-MM-dd'
from_unixtime(unix_timestamp(date, from_format), to_format)
... where from_unixtime(unix_timestamp(your_timestamp_column,'ddMMMyyyy:HH:mm:ss:SSSSSS'),'yyyy-MM-dd') between '2011-01-04' and '2011-01-20'
或
... where date(from_unixtime(unix_timestamp(your_timestamp_column,'ddMMMyyyy:HH:mm:ss:SSSSSS'))) between '2011-01-04' and '2011-01-20'
1条答案
按热度按时间ibrsph3r1#
将日期转换为可比较格式(
'yyyy-MM-dd'
)使用from_unixtime(unix_timestamp(date, from_format), to_format)
:或