Get current year, current month and current day in MySQL

Here are a few commonly used commands to find current year, current month and current day in MySQL.

Get current year in MySQL in 4 digits:

select year(now()) as 'current year';

or

select date_format(now(),'%Y') as 'current year';
+----------------+
|  current year  |
+----------------+
|     2013       |
+----------------+

Get current year in MySQL in 2 digits:

select date_format(now(),'%y') as 'current year';
+----------------+
|  current year  |
+----------------+
|       13       |
+----------------+

Get current month in MySQL:

select month(now()) as 'current month';

or

select date_format(now(),'%m') as 'current month';
+----------------+
|  current month |
+----------------+
|       12       |
+----------------+

Get current month name in MySQL:

select date_format((now(),'%M') as 'current month';
+----------------+
|  current month |
+----------------+
|    December    |
+----------------+

Get abbreviated current month name in MySQL:

select date_format((now(),'%b') as 'current month';
+----------------+
|  current month |
+----------------+
|       Dec      |
+----------------+

Get current day of the month in MySQL:

select day(now()) as 'current day';
+----------------+
|  current day   |
+----------------+
|        1       |
+----------------+
mm

About Ubiq

Ubiq is a powerful dashboard & reporting platform. Build dashboards, charts & reports for your business in minutes. Try it for free!