Hive 从配置单元中的当前_timestamp()中减去天数

Hive 从配置单元中的当前_timestamp()中减去天数,hive,hiveql,Hive,Hiveql,我想得到的时间戳正好是蜂巢中当前时间戳的前10天。我可以在配置单元中使用函数current\u timestamp()获取当前时间戳(我不想在这里使用unix\u timestamp(),因为它在配置单元的最新版本中已被弃用)。 那么,我如何得到时间戳,它正好是当前时间戳前10天?任何像添加可用天数这样的函数?:date\u sub(日期/时间戳/字符串startdate,tinyint/smallint/int-days),减去到目前为止的天数 date_sub(current_timesta

我想得到的时间戳正好是蜂巢中当前时间戳的前10天。我可以在配置单元中使用函数current\u timestamp()获取当前时间戳(我不想在这里使用unix\u timestamp(),因为它在配置单元的最新版本中已被弃用)。 那么,我如何得到时间戳,它正好是当前时间戳前10天?任何像添加可用天数这样的函数?

date\u sub(日期/时间戳/字符串startdate,tinyint/smallint/int-days)
,减去到目前为止的天数

date_sub(current_timestamp(), 10)
date_add(current_timestamp(), -10)
格式为“
yyyy-MM-dd HH:MM:ss.SSS

date_format(date_sub(current_timestamp(), 10),'yyyy-MM-dd HH:mm:ss.SSS')
或者,您也可以使用
date\u add(date/timestamp/string startdate,tinyint/smallint/int-days)
,添加到日期的天数

date_sub(current_timestamp(), 10)
date_add(current_timestamp(), -10)
date\u sub(date/timestamp/string startdate,tinyint/smallint/int-days)
,减去迄今为止的天数

date_sub(current_timestamp(), 10)
date_add(current_timestamp(), -10)
格式为“
yyyy-MM-dd HH:MM:ss.SSS

date_format(date_sub(current_timestamp(), 10),'yyyy-MM-dd HH:mm:ss.SSS')
或者,您也可以使用
date\u add(date/timestamp/string startdate,tinyint/smallint/int-days)
,添加到日期的天数

date_sub(current_timestamp(), 10)
date_add(current_timestamp(), -10)

将当前时间戳转换为unix时间戳,并减去10天=10*86400秒。然后使用
from_unixtime
获取时间戳字符串

from_unixtime(unix_timestamp(current_timestamp)-10*86400,'yyyy-MM-dd HH:mm:ss')

请注意,

当前时间戳
转换为unix时间戳,并减去10天=10*86400秒。然后使用
from_unixtime
获取时间戳字符串

from_unixtime(unix_timestamp(current_timestamp)-10*86400,'yyyy-MM-dd HH:mm:ss')

请注意,

这将返回字符串或日期对象。我想得到格式为yyyy-MM-dd HH:MM:ss的字符串。SSS@DineshRaj使用日期\格式(日期/时间戳/字符串ts,字符串fmt)将其格式化为您的需求。这也很有用。谢谢这将返回字符串或日期对象。我想得到格式为yyyy-MM-dd HH:MM:ss的字符串。SSS@DineshRaj使用日期\格式(日期/时间戳/字符串ts,字符串fmt)将其格式化为您的需求。这也很有用。谢谢