- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
In MySQL, how can we find which quarter is going on from current date or particular given date?
We can do it by providing unit value ‘quarter’ to EXTARCT() function. Examples are as follows −
mysql> Select EXTRACT(Quarter from '2017-07-29'); +------------------------------------+ | EXTRACT(Quarter from '2017-07-29') | +------------------------------------+ | 3 | +------------------------------------+ 1 row in set (0.00 sec)
Above query will give the value of quarter from a particular given date.
mysql> Select EXTRACT(Quarter from now()); +-----------------------------+ | EXTRACT(Quarter from now()) | +-----------------------------+ | 4 | +-----------------------------+ 1 row in set (0.00 sec)
Above query will give the value of quarter from the current date.
Advertisements