How to Get the Short Month Name in SQL

Below are examples that demonstrate how to use SQL to return the short month name from a date in the major RDBMSs.

MySQL

MySQL has a DATE_FORMAT() function that can be used to return the short month name from a date:

SELECT DATE_FORMAT('2030-02-01', '%b');

Result:

Feb

The language used for the month name is controlled by the value of the lc_time_names system variable. See How to Set the Locale for the Current Connection in MySQL for more information.

See How to Get the Short Month Name from a Date in MySQL for more options for returning the short month name.

SQL Server

There are several ways to do it in SQL Server. One way is to use the FORMAT() function with MMM as the format string

DECLARE @date datetime2 = '2030-08-01'; 
SELECT FORMAT(@date, 'MMM') AS 'FORMAT';

Result:

Aug

See 5 Ways to Get the Short Month Name from a Date in SQL Server for more options.

Oracle

To get the short month name in Oracle, use the TO_CHAR(datetime) function with the MON format element:

SELECT TO_CHAR(DATE '2030-09-25', 'MON')
FROM DUAL;

Result:

SEP

The capitalisation of the result reflects the capitalisation used in the format string. See Return the Short Month Name from a Date in Oracle for more information.

PostgreSQL

PostgreSQL also has a TO_CHAR() function that works similar to Oracle’s:

SELECT TO_CHAR(TIMESTAMP '2020-12-16 10:41:35', 'Mon');

Result:

Dec

See Get the Short Month Name in PostgreSQL for more information.

MariaDB

Like MySQL, MariaDB has a DATE_FORMAT() function that accepts the %b format string to return the short month name from a date.

Example:

SELECT DATE_FORMAT('2023-09-20', '%b');

Result:

Sep

One difference between the MariaDB and MySQL versions of DATE_FORMAT() is that MariaDB accepts a third argument that allows you to specify the locale (MySQL doesn’t). This means that you can specify the locale from within the function in MariaDB, without having to change the locale of the current session.

See How to Get the Short Month Name from a Date in MariaDB for more information and examples.