Back to list MySQL How to Get the Month from a Date in MySQL Database: MySQL Operators:MONTH() Problem: You’d like to get the month from a date/datetime column in a MySQL database. Example: Our database has a table named apartment_rental with data in the columns id, address, floor, and start_date. idaddressfloorstart_date 1700 Oak Street22019-03-20 2295 Main Street32019-05-31 3506 State Road12019-01-03 43949 Route 3112019-02-01 For each available apartment, get the address, the floor, and the month when it’s available. Get only the month from the start_date column. Solution: We’ll use the MONTH() function. Here’s the query you’d write: SELECT address, floor, MONTH(start_date) AS start_month FROM apartment_rental; Here’s the result of the query: addressfloorstart_month 700 Oak Street23 295 Main Street35 506 State Road11 3949 Route 3112 Discussion: Use the MONTH() function to retrieve a month from a date/datetime/timestamp column in MySQL. This function takes only one argument – either an expression which returns a date/datetime/ timestamp value or the name of a date/datetime/timestamp column. (In our example, we use the start_date column of date data type). MONTH() returns the month as an integer from 1 to 12 (1 is January and 12 is December). In our example, the apartment at 700 Oak Street will start renting in month 3 because its start date is '2019-03-20' Recommended courses: SQL Basics Standard SQL Functions SQL Practice Set Recommended articles: 18 Useful Important SQL Functions to Learn ASAP Performing Calculations on Date- and Time-Related Values How Often Employees Are Running Late for Work: SQL Datetime and Interval SQL Arithmetic See also: How to Get the Date from a Datetime Column in MySQL How to Find the Last Day of the Month for a Given Date in MySQL How to Get the Year from a Datetime Column in MySQL How to Add Time to a Datetime Value in MySQL Tags: MySQL Subscribe to our newsletter Join our weekly newsletter to be notified about the latest posts.