I want to TRIM(LEADING 0 FROM month) FROM table1
where table1
has column month
with data formatted like so: 01, 02, 03
I would like to update the data so it is formatted as: 1, 2, 3, ...
Thanks!
I want to TRIM(LEADING 0 FROM month) FROM table1
where table1
has column month
with data formatted like so: 01, 02, 03
I would like to update the data so it is formatted as: 1, 2, 3, ...
Thanks!
Simplest way might be to just cast it to an int:
SELECT CAST(month as int) from table
From the MySQL docs:
mysql> SELECT MONTH('2008-02-03');
-> 2
So, if you only have the month (and not the rest of the date), you could use:
SELECT MONTH(CONCAT('2010-', month, '-', '01')) FROM table1;
Source: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_month