TO_WEEK_OF_YEAR (Lakehouse v1)
Calculates the week number within a year for a given date.
ISO week numbering works as follows: January 4th is always considered part of the first week. If January 1st is a Thursday, then the week that spans from Monday, December 29th, to Sunday, January 4th, is designated as ISO week 1. If January 1st falls on a Friday, then the week that goes from Monday, January 4th, to Sunday, January 10th, is marked as ISO week 1.
Analyze Syntax
Section titled “Analyze Syntax”func.to_week_of_year(<expr>)Analyze Examples
Section titled “Analyze Examples”func.now(), func.to_week_of_year(func.now()), func.week(func.now()), func.weekofyear(func.now())
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│ func.now() │ func.to_week_of_year(func.now()) │ func.week(func.now()) │ func.weekofyear(func.now()) │├────────────────────────────┼──────────────────────────────────┼───────────────────────┼─────────────────────────────┤│ 2024-03-14 23:30:04.011624 │ 11 │ 11 │ 11 │└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘SQL Syntax
Section titled “SQL Syntax”TO_WEEK_OF_YEAR(<expr>)Arguments
Section titled “Arguments”| Arguments | Description |
|---|---|
<expr> | date/timestamp |
Aliases
Section titled “Aliases”Return Type
Section titled “Return Type”Returns an integer that represents the week number within a year, with numbering ranging from 1 to 53.
SQL Examples
Section titled “SQL Examples”SELECT NOW(), TO_WEEK_OF_YEAR(NOW()), WEEK(NOW()), WEEKOFYEAR(NOW());
┌───────────────────────────────────────────────────────────────────────────────────────┐│ now() │ to_week_of_year(now()) │ week(now()) │ weekofyear(now()) │├────────────────────────────┼────────────────────────┼─────────────┼───────────────────┤│ 2024-03-14 23:30:04.011624 │ 11 │ 11 │ 11 │└───────────────────────────────────────────────────────────────────────────────────────┘