从 Hive 中的 current_timestamp() 中减去天数

Din*_*Raj 1 hive hiveql

我想获得 Hive 中当前时间戳前 10 天的时间戳。我可以使用 hive 中的函数 current_timestamp() 获取当前时间戳(我不想在这里使用 unix_timestamp() 因为它在最近版本的 hive 中已弃用)。那么,如何获得当前时间戳前 10 天的时间戳?任何像 add_days 这样的函数可用?

VK_*_*217 6

来源date_sub(date/timestamp/string startdate, tinyint/smallint/int days),减去迄今为止的天数

date_sub(current_timestamp(), 10)
Run Code Online (Sandbox Code Playgroud)

格式为“ yyyy-MM-dd HH:mm:ss.SSS

date_format(date_sub(current_timestamp(), 10),'yyyy-MM-dd HH:mm:ss.SSS')
Run Code Online (Sandbox Code Playgroud)

或者,您也可以使用date_add(date/timestamp/string startdate, tinyint/smallint/int days), 添加迄今为止的天数

date_add(current_timestamp(), -10)
Run Code Online (Sandbox Code Playgroud)