DAYNAME
DAYNAME(date)
Section titled “DAYNAME(date)”- date: This parameter refers to the date from which the day of the week is to be extracted. It accepts a value of the DATE, DATETIME, or TIMESTAMP type. DAYNAME(date) returns a string representing the day of the week for the provided date.
Example
Section titled “Example”SELECT DAYNAME('2023-12-25') AS 'Day';Output
Section titled “Output”+-------+| Day |+-------+| Monday|+-------+Explanation
Section titled “Explanation”The DAYNAME function in SQL returns the day of the week for a specified date. In this example, the function is used to determine the day of the week for December 25, 2023, which returns ‘Monday’.
DAYNAME(date)
Section titled “DAYNAME(date)”- date: This is the input parameter that specifies the date from which the name of the day will be extracted. It must be a valid expression and in a date data type format.
Example
Section titled “Example”SELECT DAYNAME('2021-12-22') AS 'Day';Output
Section titled “Output”+-------+| Day |+-------+| Wednesday |+-------+Explanation
Section titled “Explanation”The DAYNAME() function in SQL is used to return the name of the weekday for a specific date. In the given example, it returns ‘Wednesday’ as ‘2021-12-22’ falls on a Wednesday.
DAYNAME(date)
Section titled “DAYNAME(date)”- date: The parameter represents a valid date expression from which Oracle extracts the day of the week as a string.
Example
Section titled “Example”SELECT TO_CHAR(date '2022-05-28', 'day') AS dayFROM dual;Output
Section titled “Output”SATURDAYExplanation
Section titled “Explanation”The TO_CHAR function in Oracle SQL is used to convert a DATE or TIMESTAMP value to a string. In the above example, the TO_CHAR function has been utilized to retrieve the name of the day from a specific date ‘2022-05-28’. The date is first specified, then the ‘day’ format model is provided as an argument to the TO_CHAR function, which then returns the full name of the day for that specific date. In the case above, the output is ‘SATURDAY’, which is the name of the day for the date ‘2022-05-28’.