How to convert a date column to TIMESTAMP in SQL

Somethimes we need to get from the database the data before/after a certain date or between two dates. In this tutorial I will explain how you can convert a date column to TIMESTAMP in a easy way.

You will be able to convert a date or date time column to TIMESTAMP. Supposing you have 2016-04-22 08:35:29 you will get 1461328529 or 2016-04-22 you will get 1461297600. To do that you need the function UNIX_TIMESTAMP.

Example:

SELECT UNIX_TIMESTAMP(date) FROM mytable

I hope you will find useful this tutorial.









Leave a Comment