Skip to main content

toStartOfWeek

Returns the first day of the year for a date or a date with time.

Syntax

toStartOfWeek(expr)

Arguments

ArgumentsDescription
exprdate16/date32/datetime

Return Type

Datetime object, returns date in “YYYY-MM-DD” format.

Examples

SELECT toStartOfWeek(now());
+----------------------+
| toStartOfWeek(now()) |
+----------------------+
| 2022-03-27 |
+----------------------+

SELECT toStartOfWeek(toDateTime(1630812366));
+---------------------------------------+
| toStartOfWeek(toDateTime(1630812366)) |
+---------------------------------------+
| 2021-09-05 |
+---------------------------------------+