Back to list SQL Server How to Get the Month from a Date in T-SQL Database: SQL Server Operators:MONTH() Problem: You’d like to get the month from a date field in a SQL Server database. Example: Our database has a table named Furniture with data in the columns Id, Name, and ProducedDate. IdNameProducedDate 1sofa2018-01-10 2chair2018-01-05 3desk2018-06-20 4bookcase2018-11-15 Let’s get the month from each product’s ProducedDate and find out which furniture was produced in a given month. Solution: We’ll use the MONTH() function. Here’s the query you would write: SELECT Name, MONTH(ProducedDate) AS ProducedMonth FROM Furniture; Here’s the result of the query: NameProducedMonth sofa1 chair1 desk6 bookcase11 Discussion: To get a month from a date field in SQL Server, use the MONTH() function. This function takes only one argument – the date. This can be a date or date and time data type. (In our example, the column ProducedDate is of the date data type.) The argument can be a column name or an expression. (In our example, it is the ProducedDate column). MONTH() returns the month number as an integer from 1 to 12. For the desk item, the ProducedMonth value is 6 (returned from the 'YYYY-MM-DD' date '2018-06-20'). Recommended courses: SQL Basics in SQL Server Common Functions in SQL Server Recommended articles: 5 SQL Functions for Manipulating Strings 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 Year from a Date in T-SQL Tags: SQL Server Subscribe to our newsletter Join our weekly newsletter to be notified about the latest posts.