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\u 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;
1条答案
按热度按时间p8ekf7hl1#
如果regdate和subscr\u date是字符串:
如果regdate是bigint,subscr\u date是字符串:
如果注册日期和子注册日期为2012-07-19,当前注册日期为2016-09-01,则结果为:
注册日1504子注册日1504