DATE_PART (Lakehouse v1)
Extrait la partie indiquée d’une date, d’une heure ou d’un horodatage.
Voir aussi : EXTRACT
Syntaxe Analyze
Section intitulée « Syntaxe Analyze »func.date_part(<unit>, <date_or_time_expr>)Exemples Analyze
Section intitulée « Exemples Analyze »func.now() |---------------------+2023-10-16 02:09:28.0|
func.date_part('day', now())
func.date_part('day', now())|----------------------------+ 16 |Syntaxe SQL
Section intitulée « Syntaxe SQL »DATE_PART( YEAR | QUARTER | MONTH | WEEK | DAY | HOUR | MINUTE | SECOND | DOW | DOY, <date_or_time_expr> )- DOW : jour de la semaine.
- DOY : jour de l’année.
Type de retour
Section intitulée « Type de retour »Entier.
Exemples SQL
Section intitulée « Exemples SQL »SELECT NOW();
now() |---------------------+2023-10-16 02:09:28.0|
SELECT DATE_PART(DAY, NOW());
date_part(day, now())|---------------------+ 16|
-- October 16, 2023, is a MondaySELECT DATE_PART(DOW, NOW());
date_part(dow, now())|---------------------+ 1|
-- October 16, 2023, is the 289th day of the yearSELECT DATE_PART(DOY, NOW());
date_part(doy, now())|---------------------+ 289|
SELECT DATE_PART(MONTH, TO_DATE('2022-05-13'));
date_part(month, to_date('2022-05-13'))|---------------------------------------+ 5|