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 di MS Access DateDiff()

❮ Funzioni di MS Access

Esempio

Restituisce la differenza tra due date, in anni:

SELECT DateDiff("yyyy", #13/01/1998#, #09/05/2017#);

Definizione e utilizzo

La funzione DateDiff() restituisce la differenza tra due date.

Sintassi

DateDiff(datepart, date1, date2, firstdayofweek, firstweekofyear)

Valori dei parametri

Parameter Description
datepart Required. The 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
date1 and date2 Required. The two dates to calculate the difference between
firstdayofweek Optional. Specifies the first day of the week. Can be one of the following values:
  • 0 = Use the NLS API setting
  • 1 = Sunday (this is 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

Restituisce la differenza tra due date, in mesi:

SELECT DateDiff("m", #13/01/1998#, #09/05/2017#);

Esempio

Restituisce la differenza tra una data specificata e la data odierna, in giorni:

SELECT DateDiff("d", #13/01/1998#, Date());

❮ Funzioni di MS Access