从 PRESTO 中的日期时间截断时间
Truncate time from datetime in PRESTO
我需要在 Presto 中从日期时间截断时间。
我注意到我不能使用 Redshift 中使用的 Trunc() 函数来实现相同的目的。
date_trunc() returns 时间戳再次重置为开始。
Cast 迄今为止的日期时间
CAST(x AS DATE)
date(x) -- This is an alias for CAST(x AS DATE).
IF 要转换的 date/time 值保存为字符串,这样的转换可能会失败;其中推荐使用TRY_CAST()
,如果转换失败则为returns NULL。
我需要在 Presto 中从日期时间截断时间。 我注意到我不能使用 Redshift 中使用的 Trunc() 函数来实现相同的目的。
date_trunc() returns 时间戳再次重置为开始。
Cast 迄今为止的日期时间
CAST(x AS DATE)
date(x) -- This is an alias for CAST(x AS DATE).
IF 要转换的 date/time 值保存为字符串,这样的转换可能会失败;其中推荐使用TRY_CAST()
,如果转换失败则为returns NULL。