Categories:

Date & Time Functions

DAYNAME

Extracts the three-letter day-of-week name from the specified date or timestamp.

Syntax

DAYNAME( <date_or_timestamp_expr> )

Examples

Get the abbreviation for the day of the week of January 1, 2015:

SELECT DAYNAME(TO_DATE('2015-05-01')) AS DAY;
+-----+
| DAY |
|-----|
| Fri |
+-----+

Get the abbreviation for the day of the week of January 1, 2015:

SELECT DAYNAME(TO_TIMESTAMP_NTZ('2015-05-02 10:00')) AS DAY;
+-----+
| DAY |
|-----|
| Sat |
+-----+

Get the abbreviation for the day of the week for each day from January 1, 2015 to January 8 2015:

CREATE TABLE dates (d DATE);
INSERT INTO dates (d) VALUES 
    ('2015-01-01'::DATE),
    ('2015-01-02'::DATE),
    ('2015-01-03'::DATE),
    ('2015-01-04'::DATE),
    ('2015-01-05'::DATE),
    ('2015-01-06'::DATE),
    ('2015-01-07'::DATE),
    ('2015-01-08'::DATE);
SELECT d, DAYNAME(d) 
    FROM dates
    ORDER BY d;
+------------+------------+
| D          | DAYNAME(D) |
|------------+------------|
| 2015-01-01 | Thu        |
| 2015-01-02 | Fri        |
| 2015-01-03 | Sat        |
| 2015-01-04 | Sun        |
| 2015-01-05 | Mon        |
| 2015-01-06 | Tue        |
| 2015-01-07 | Wed        |
| 2015-01-08 | Thu        |
+------------+------------+