MySQL – Convert TIMESTAMP to INTEGER

[adsense id=”0514458240″ width=”468″ height=”60″]

I have seen this question raised several times. How can we convert a timestamp to an INTEGER. This is achieved by using the CAST function available in MySQL.

Here is an example:

mysql> select cast(current_timestamp as unsigned);
+-------------------------------------+
| cast(current_timestamp as unsigned) |
+-------------------------------------+
|                      20120420174927 | 
+-------------------------------------+
1 row in set (0.00 sec)