This question already has an answer here:
When I am querying with MONTH(DATE) return 1
if date is in january,I want to return 01
instead of 1
,
ie,Prefixing 0
for common standard.
January
- 01
February
- 02
March
- 03
etc, How it is possible in MySQL?
</div>
Yes month()
will give you the month number, for prefixing 0 you may use date_format
function.
mysql> select date_format(curdate(),'%m');
+-----------------------------+
| date_format(curdate(),'%m') |
+-----------------------------+
| 05 |
+-----------------------------+
1 row in set (0.01 sec)