MulaiMulai sekarang secara gratis

Modifying the value of a date

Adding different date parts to a date expression proves to be useful in many scenarios. You can calculate, for example:

  • The delivery date of an order, by adding 3 days to the order date
  • The dates when a bonus is received, knowing that they are received every 3 months, starting with a certain date.

In SQL Server, you can use DATEADD() for adding date parts to a date. In this exercise, you will get familiar with this function.

Latihan ini adalah bagian dari kursus

Functions for Manipulating Data in SQL Server

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

SELECT 
	first_name,
	birthdate,
    -- Add 18 years to the birthdate
	___(___, ___, ___) AS eighteenth_birthday
  FROM voters;
Edit dan Jalankan Kode