如何根据另一个日期列创建 'Week column'?
How to create 'Week column' based on another date column?
I have column 'jobstarttimeiso' and I want to create another column for Weeks of the year based on the date. How would I go about doing that? I am using Redash to query from redshift database. Please help! Thank you.
提取函数将return一个星期数,例如
select extract(week from jobstarttimeiso) as weeknumber
总的来说:
EXTRACT ( datepart FROM { TIMESTAMP 'literal' | timestamp } )
参见:https://docs.aws.amazon.com/redshift/latest/dg/r_EXTRACT_function.html
或者你也可以使用 to_char()
TO_CHAR (timestamp_expression | numeric_expression , 'format')
使用参数 IYYY
作为 ISO 8601 周编号年份(4 位或更多位)的格式
提取函数将return一个星期数,例如
select extract(week from jobstarttimeiso) as weeknumber
总的来说:
EXTRACT ( datepart FROM { TIMESTAMP 'literal' | timestamp } )
参见:https://docs.aws.amazon.com/redshift/latest/dg/r_EXTRACT_function.html
或者你也可以使用 to_char()
TO_CHAR (timestamp_expression | numeric_expression , 'format')
使用参数 IYYY
作为 ISO 8601 周编号年份(4 位或更多位)的格式