Siri
Siri

Reputation: 1414

How to extract date from a timestamp who data type is int

The existing database's table has a column "dateline" with int data type. It stores timestamp. How can I extract date from it.

Dateline (int)
_____________
1314182844
1298122381
1298122956

Advise on how can I extract the date part from this in the following query.

select * from TableName where Dateline between '2013-10-01' and '2013-10-31'

I tried using cast, dateformat, convert, but nothing gave the desired result.

P.S. PLEASE NOTE THE DATA TYPE STORAGE IS INTEGER..

Upvotes: 0

Views: 392

Answers (1)

Mr47
Mr47

Reputation: 2655

You can use FROM_UNIXTIME(Dateline).

See more information here.

As atomman mentions in the comments, you should use DATE(FROM_UNIXTIME(Dateline)) if you only want the date part.

Upvotes: 3

Related Questions