MulaiMulai sekarang secara gratis

Extracting parts from a date

In this exercise, you will practice extracting date parts from a date, using SQL Server built-in functions. These functions are easy to apply and you can also use them in the WHERE clause, to restrict the results returned by the query.

You will start by querying the voters table and create new columns by extracting the year, month, and day from the first_vote_date.

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,
	last_name,
	-- Extract the year of the first vote
	___  AS first_vote_year,
    -- Extract the month of the first vote
	___ AS first_vote_month,
    -- Extract the day of the first vote
	___   AS first_vote_day
FROM voters;
Edit dan Jalankan Kode