如何获取当前_日期和Hive中存档的时间之间的天数?
mytable中有两个时间戳: “regdate”的格式为bigint,例如“20120719044326”; “subscr_date”,例如“如何获取当前_日期和Hive中存档的时间之间的天数?,hive,unix-timestamp,Hive,Unix Timestamp,mytable中有两个时间戳: “regdate”的格式为bigint,例如“20120719044326”; “subscr_date”,例如“2012-07-19 04:43:26”的格式为不同的国家字符 我想将当前_日期和regdate之间的天数作为reg_天数;当前日期和子CRU日期之间的天数为子CRU天 那么如何在配置单元中编写查询呢?如果regdate和subscr\u date是字符串: select datediff(current_date,from_unixtime(unix
2012-07-19 04:43:26
”的格式为不同的国家字符
我想将当前_日期和regdate之间的天数作为reg_天数;当前日期和子CRU日期之间的天数为子CRU天
那么如何在配置单元中编写查询呢?如果regdate和subscr\u date是字符串:
select datediff(current_date,from_unixtime(unix_timestamp(unix_timestamp(regdate, 'yyyyMMddhhmmss'), 'yyyy-MM-dd')) as reg_days,
datediff(current_date,from_unixtime(unix_timestamp(subscr_date, 'yyyy-MM-dd hh:mm:ss'), 'yyyy-MM-dd')) as subscr_days
from mytable;
如果regdate是BigInt,subscr_date是字符串:
select datediff(current_date,from_unixtime(unix_timestamp(unix_timestamp(CAST(regdate AS STRING), 'yyyyMMddhhmmss'), 'yyyy-MM-dd')) as reg_days,
datediff(current_date,from_unixtime(unix_timestamp(subscr_date, 'yyyy-MM-dd hh:mm:ss'), 'yyyy-MM-dd')) as subscr_days
from mytable;
如果登记日期和子登记日期为2012-07-19,而当前日期为2016-09-01,则结果为:
注册日1504子注册日1504如果注册日和子注册日为字符串:
select datediff(current_date,from_unixtime(unix_timestamp(unix_timestamp(regdate, 'yyyyMMddhhmmss'), 'yyyy-MM-dd')) as reg_days,
datediff(current_date,from_unixtime(unix_timestamp(subscr_date, 'yyyy-MM-dd hh:mm:ss'), 'yyyy-MM-dd')) as subscr_days
from mytable;
如果regdate是BigInt,subscr_date是字符串:
select datediff(current_date,from_unixtime(unix_timestamp(unix_timestamp(CAST(regdate AS STRING), 'yyyyMMddhhmmss'), 'yyyy-MM-dd')) as reg_days,
datediff(current_date,from_unixtime(unix_timestamp(subscr_date, 'yyyy-MM-dd hh:mm:ss'), 'yyyy-MM-dd')) as subscr_days
from mytable;
如果登记日期和子登记日期为2012-07-19,而当前日期为2016-09-01,则结果为:
reg_天1504subscr_天1504两个regdate和subscr_日期指示相同的日期?两个regdate和subscr_日期指示相同的日期?