Last updated 1 year ago
This function returns a character string representing the specified datepart of the specified date. ().
DATENAME ( datepart , date )
This transformation uses several functions depending on the inputs
DATE_PART( <date_or_time_part> , <date_or_time_expr> ) MONTHNAME( <date_or_timestamp_expr> ) DAYNAME( <date_or_timestamp_expr> )
Code:
SELECT DATENAME(month, getdate()) AS DATE1, DATENAME(day, getdate()) AS DATE2, DATENAME(dw, GETDATE()) AS DATE3;
Result:
DATE1|DATE2|DATE3 | -----+-----+-------+ May |3 |Tuesday|
SELECT MONTHNAME(CURRENT_TIMESTAMP() :: TIMESTAMP) AS DATE1, DAYNAME(CURRENT_TIMESTAMP() :: TIMESTAMP) AS DATE2, DAYNAME(CURRENT_TIMESTAMP() :: TIMESTAMP) AS DATE3;
DATE1|DATE2|DATE3 | -----+-----+------+ May |Tue |Tue |