Extraer partes de una fecha
En este ejercicio practicarás cómo extraer partes de una fecha usando las funciones integradas de SQL Server. Estas funciones son fáciles de aplicar y también puedes usarlas en la cláusula WHERE para restringir los resultados que devuelve la consulta.
Empezarás consultando la tabla voters y crearás columnas nuevas extrayendo el año, el mes y el día de first_vote_date.
Este ejercicio forma parte del curso
Funciones para manipular datos en SQL Server
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
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;