MONTHNAME
MONTHNAME(date)
Section titled “MONTHNAME(date)”- date: This parameter represents the date from which the function will extract the month name. The data type of this parameter can be a date, datetime, or a string in an appropriate format.
Example
Section titled “Example”SELECT MONTHNAME('2021-05-20') AS 'Month';Output
Section titled “Output”| Month ||-------|| May |Explanation
Section titled “Explanation”The MONTHNAME function in SQL is used to get the name of the month from the specified date. In the above example, it is extracting the month name (May) from the date ‘2021-05-20’.
MONTHNAME( date )
Section titled “MONTHNAME( date )”- date: The date value from which the name of the month is retrieved. It can be any valid date expression. This function will return the full name of the month corresponding to the date provided as a string.
Example
Section titled “Example”SELECT MONTHNAME('2022-09-15') AS Month_Name;Output
Section titled “Output”+------------+| Month_Name |+------------+| September |+------------+Explanation
Section titled “Explanation”In the above SQL command, the MONTHNAME function is used to extract the month name from the date provided (‘2022-09-15’). The result is ‘September’.
MONTHNAME(date)
Section titled “MONTHNAME(date)”- date: This parameter accepts a DATE or an expression that can be evaluated to a DATE. It represents the date from which the month name is to be extracted. The value returned by the MONTHNAME function is a string representing the name of the month of the input date in uppercase.
Example
Section titled “Example”SELECT TO_CHAR(TO_DATE('14-JUL-21', 'DD-MON-YY'), 'MONTH') AS MonthName FROM dual;Output
Section titled “Output”MonthName---------JULYExplanation
Section titled “Explanation”This command extracts the full month name from the provided date string ‘14-JUL-21’. The TO_DATE function converts the date string into a date format, and the TO_CHAR function converts this date into a string of full month name. The SQL query returns ‘JULY’ as the full month name.