invantive documentationpart of invantive cloud
Invantive Support ForumsLog In / Sign Up

DAYOFWEEK

Syntax

%%{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:

select dayofweek(to_date('20260603', 'YYYYMMDD'))

-------------------
3

The following example retrieves the day number within a week of a date:

select dayofweek(to_date('20260531', 'YYYYMMDD'))

-------------------
0