Esercitazione SQL

SQL HOME Introduzione SQL Sintassi SQL Seleziona SQL SQL Seleziona distinto SQL dove SQL e, o, no Ordina SQL per Inserisci SQL in Valori nulli SQL Aggiornamento SQL Elimina SQL SQL Seleziona in alto SQL Min e Max Conteggio SQL, media, somma Mi piace SQL Caratteri jolly SQL SQL In SQL tra Alias ​​SQL Join SQL Join interno SQL Join sinistro SQL SQL Right Join SQL Full Join SQL Self Join Unione SQL Raggruppamento SQL per SQL Avere SQL esiste SQL Qualsiasi, Tutti SQL Seleziona in Inserisci SQL in Seleziona Caso SQL Funzioni SQL Null Stored procedure SQL Commenti SQL Operatori SQL

Database SQL

SQL Crea DB SQL Drop DB DB di backup SQL SQL Crea tabella Tabella di rilascio SQL SQL Alter tabella Vincoli SQL SQL non nullo SQL unico Chiave primaria SQL Chiave esterna SQL Controllo SQL SQL predefinito Indice SQL Incremento automatico SQL Date SQL Viste SQL SQL Injection Hosting SQL Tipi di dati SQL

Riferimenti SQL

Parole chiave SQL Funzioni MySQL Funzioni di SQL Server Funzioni di accesso MS Riferimento rapido SQL

Esempi SQL

Esempi SQL Quiz SQL Esercizi SQL Certificato SQL

Funzione DatePart() di MS Access

Esempio

Restituire la parte dell'anno della data specificata:

SELECT DatePart("yyyy", #09/05/2017#);

Definizione e utilizzo

La funzione DatePart() restituisce una parte specificata di una data, come numero intero.

Sintassi

DatePart(datepart, date, firstdayofweek, firstweekofyear)

Valori dei parametri

Parameter Description
datepart Required. The date part to return. Can be one of the following values:
  • yyyy = Year
  • q = Quarter
  • m = month
  • y = Day of the year
  • d = Day
  • w = Weekday
  • ww = Week
  • h = hour
  • n = Minute
  • s = Second
date Required. The date value to be evaluated
firstdayofweek Optional. Specifies the first day of the week. Can be one of the following values:
  • 0 = Use the NLS API setting
  • 1 = Sunday (default)
  • 2 = Monday
  • 3 = Tuesday
  • 4 = Wednesday
  • 5 = Thursday
  • 6 = Friday
  • 7 = Saturday
firstdayofyear Optional. Specifies the first week of the year. Can be one of the following values:
  • 0 = Use the NLS API setting
  • 1 = Use the first week that includes Jan 1st (default)
  • 2 = Use the first week in the year that has at least 4 days
  • 3 = Use the first full week of the year

Dettagli tecnici

Funziona in: Da Access 2000

Altri esempi

Esempio

Restituire la parte del mese della data specificata:

SELECT DatePart("m", #09/05/2017#);

Esempio

Restituisci il giorno della settimana della data odierna:

SELECT DatePart("w", Date());