---
title: "DAYOFWEEK"
description: "The DAYOFWEEK SQL function collects the day of a week from a date."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/dayofweek
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/dayofweek
updated: 2026-08-09T00:00:00Z
license: https://documentation.invantive.eu/en/
---

## Syntax
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> DAYOFWEEK[DAYOFWEEK]:::quoted
    DAYOFWEEK --> End((END))
```

## Purpose
The `DAYOFWEEK` SQL function collects the day of a week from a date. Day numbering starts at 0 for Sunday and ends at 6 for Saturday.

Parameters:
- Input (`datetime`): the date/time.

Returns: the day of a week as `int32`.

## Examples
The following example retrieves the day number within a week of a date:
```sql
select dayofweek(to_date('20260603', 'YYYYMMDD'))

-------------------
3
```
The following example retrieves the day number within a week of a date:
```sql
select dayofweek(to_date('20260531', 'YYYYMMDD'))

-------------------
0
```