当我使用trunc(timestamp, 'D')
时,它总是给我那周的星期一。是否有可能要求函数返回一周中的其他日期,例如星期二?谢谢!
答案 0 :(得分:1)
您应该使用trunc(timestamp, 'J')
。请参阅Day的文档,您正在使用'一周的开始日期':
trunc(timestamp, string unit)
Purpose: Strips off fields from a TIMESTAMP value.
Unit argument: The unit argument value is case-sensitive. This argument string can be one of:
SYYYY, YYYY, YEAR, SYEAR, YYY, YY, Y: Year.
Q: Quarter.
MONTH, MON, MM, RM: Month.
WW, W: Same day of the week as the first day of the month.
DDD, DD, J: Day.
DAY, DY, D: Starting day of the week. (Not necessarily the current day.)
HH, HH12, HH24: Hour. A TIMESTAMP value truncated to the hour is always represented in 24-hour notation, even for the HH12 argument string.
MI: Minute.
https://www.cloudera.com/documentation/enterprise/latest/topics/impala_datetime_functions.html
答案 1 :(得分:0)
简单,试试吧 SELECT TRUNC(时间戳,'D')+ INTERVAL 1 DAY;