SQL -zelfstudie

SQL HOME SQL-intro SQL-syntaxis SQL-selectie SQL Select Distinct SQL waar SQL en, of, niet SQL-bestelling op SQL invoegen in SQL-nulwaarden SQL-update SQL verwijderen SQL Selecteer Top SQL Min en Max Aantal SQL, Gem, Som SQL Vind ik leuk SQL-jokertekens SQL In SQL Tussen SQL-aliassen SQL-joins SQL Inner Join SQL Left Join SQL juiste join Volledige deelname aan SQL Zelf lid worden van SQL SQL-unie SQL Groeperen op SQL hebben SQL bestaat SQL Alle, Alle SQL Selecteren in SQL invoegen in selecteren SQL-geval SQL Null-functies Op SQL opgeslagen procedures SQL-opmerkingen SQL-operators

SQL- database

SQL creëren DB SQL Drop-DB SQL back-up DB SQL-tabel maken SQL-droptabel SQL-wijzigingstabel SQL-beperkingen SQL niet null SQL Uniek Primaire SQL-sleutel SQL externe sleutel SQL-controle SQL-standaard SQL-index Automatische SQL-verhoging SQL-datums SQL-weergaven SQL injectie SQL-hosting SQL-gegevenstypen

SQL- verwijzingen

SQL-trefwoorden MySQL-functies SQL Server-functies MS Access-functies Snelle SQL-referentie

SQL- voorbeelden

SQL-voorbeelden SQL-quiz SQL-oefeningen SQL-certificaat

MS Access DateDiff() Functie

❮MS Access-functies

Voorbeeld

Retourneer het verschil tussen twee datums, in jaren:

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

Definitie en gebruik

De functie DateDiff() retourneert het verschil tussen twee datums.

Syntaxis

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

Parameterwaarden

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

Technische details

Werkt in: Van Access 2000

Meer voorbeelden

Voorbeeld

Retourneer het verschil tussen twee datums, in maanden:

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

Voorbeeld

Retourneer het verschil tussen een opgegeven datum en de datum van vandaag, in dagen:

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

❮MS Access-functies