# WEEK

Extracts the “week number” from the given datetime.&#x20;

There are eight ways to number weeks, described below.

## Syntax

```
WEEK ( dateobj, [mode] )
WEEKOFYEAR ( dateobj )

```

## Arguments

* dateobj: a valid date, datetime, or parsable date string.
* mode: a number from 0 to 7, corresponding to the mode desired.

| Mode | Description                    | Counting from            |
| ---- | ------------------------------ | ------------------------ |
| 0    | Week (0 to 53) starting Sunday | First week with a Sunday |
| 1    | Week (0 to 53) starting Monday | First week with 4+ days  |
| 2    | Week (1 to 53) starting Sunday | First week with a Sunday |
| 3    | Week (1 to 53) starting Monday | First week with 4+ days  |
| 4    | Week (0 to 53) starting Sunday | First week with 4+ days  |
| 5    | Week (0 to 53) starting Monday | First week with a Monday |
| 6    | Week (1 to 53) starting Sunday | First week with 4+ days  |
| 7    | Week (1 to 53) starting Monday | First week with a Monday |

> **❗ Important**: `WEEKOFYEAR (date)` is equivalent to `WEEK(date, 3)`.

## Return Type

Integer

## Examples

```sql
SELECT WEEK('2009-02-13 23:31:30', 7);

```

```output

+--------------------------------+
| WEEK('2009-02-13 23:31:30', 7) |
+--------------------------------+
|                              6 |
+--------------------------------+

```

**Related Topics**

* [WEEKDAY](https://docs.singlestore.com/cloud/reference/sql-reference/date-and-time-functions/weekday.md)
* [MONTH](https://docs.singlestore.com/cloud/reference/sql-reference/date-and-time-functions/month.md)
* [YEAR](https://docs.singlestore.com/cloud/reference/sql-reference/date-and-time-functions/year.md)

***

Modified at: May 31, 2023

Source: [/cloud/reference/sql-reference/date-and-time-functions/week/](https://docs.singlestore.com/cloud/reference/sql-reference/date-and-time-functions/week/)

(An index of the documentation is available at /llms.txt)
