 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we fetch month and day from a given date in MySQL?
It can be done inflowing two ways −
(A) With the help of EXRACT() function - EXTRACT() function can fetch any part from MySQL TIMESTAMP value. Following is the example of fetching month and day from a given date.
mysql> Select EXTRACT(Month from '2017-10-22') AS 'MONTH'; +-------+ | MONTH | +-------+ | 10 | +-------+ 1 row in set (0.00 sec) mysql> Select EXTRACT(day from '2017-10-22')AS 'DAY'; +------+ | DAY | +------+ | 22 | +------+ 1 row in set (0.00 sec)
(B) With the help of MONTH() or DAY() function - Rather than passing month and day as one of the arguments of EXTRACT() function, we can use MONTH() and DAY() function to fetch the value of MONTH and DAY from a given date as follows −
mysql> Select DAY('2017-10-22')AS 'DAY'; +------+ | DAY  | +------+ |   22 | +------+ 1 row in set (0.00 sec) mysql> Select MONTH('2017-10-22')AS 'MONTH'; +-------+ | MONTH | +-------+ |    10 | +-------+ 1 row in set (0.00 sec)Advertisements
 