
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Convert DATE timestamp to return only the month name in MySQL
To return only the month name, you can use DATE_FORMAT() −
mysql> create table DemoTable1999 ( ArrivalDate timestamp ); Query OK, 0 rows affected (0.66 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1999 values('2019-01-01 12:34:00'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1999 values('2019-12-31 10:04:00'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1999 values('2018-10-11 04:04:30'); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1999;
This will produce the following output −
+---------------------+ | ArrivalDate | +---------------------+ | 2019-01-01 12:34:00 | | 2019-12-31 10:04:00 | | 2018-10-11 04:04:30 | +---------------------+ 3 rows in set (0.00 sec)
Here is the query to return the month name −
mysql> select date_format(ArrivalDate,'%M') as MonthName from DemoTable1999;
This will produce the following output −
+-----------+ | MonthName | +-----------+ | January | | December | | October | +-----------+ 3 rows in set (0.05 sec)
- Related Articles
- Convert DATE timestamp to return the month number
- MySQL query to convert timestamp to month?
- Get only the date in timestamp in MySQL?
- MySQL query to update only month in date?
- Display only date from timestamp value in MySQL
- Convert MySQL Unix-Timestamp format to date format?
- Convert datetime to get month name in MySQL?
- Want to fetch only the month part from a date in MySQL
- Format MySQL date and convert to year-month-day
- Output only the name of the month instead of the month number in MySQL
- Convert MySQL timestamp to UNIX Timestamp?
- Convert date string to timestamp in Python
- Compare only day and month with date field in MySQL?
- How to convert date to timestamp in MongoDB
- How to convert Python date to Unix timestamp?

Advertisements