Documentazione Invantiveparte di invantive cloud
Forum di supporto InvantiveAccedi / Registrati

DATEPART

Sintassi

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

Scopo

La funzione SQL DATEPART ottiene la parte specificata da una datetime.

Parametri:

  • Date part (varchar2): the part to be extracted, chosen from year, yyyy, yy, quarter, qq, q, month, mm, m, day, dy, y, week, ww, wk, hour, hh, minute, mi, n, second, ss, s, millisecond, ms, microsecond, mcs, nanosecond and ns.
  • date (datetime): il valore da cui ottenere la parte.

Restituisce: il valore della parte selezionata della data/ora come int32. null viene restituito quando viene scelta una parte di data non esistente.

Esempi

Il seguente esempio recupera la parte del mese di una data:

select datepart('month', to_date('2016-12-31', 'YYYY-MM-DD'))

-------------------
12

Il seguente esempio recupera la parte della settimana di una data:

select datepart('week', to_date('2016-12-31', 'YYYY-MM-DD'))

-------------------
52