dfherr
dfherr

Reputation: 1642

Mysql Incorrect datetime value when doing select on timestamp with unixtime value

Okay, so I got this probably very easy problem, but only find answers for the opposite approach.

I have this mysql column: timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

when i try to:

select * from table where timestamp > 1440586108

i get the following warning: Incorrect datetime value '1440586108' for column timestamp at row 1

How should i do it properly?

Upvotes: 1

Views: 1445

Answers (2)

Parris Varney
Parris Varney

Reputation: 11488

Timestamp has format yyyy-mm-dd H:i:s

See the docs

What you need is FROM_UNIXTIME()

Select * from table where timestamp > FROM_UNIXTIME(1440586108)

Upvotes: 2

mynawaz
mynawaz

Reputation: 1594

Use FROM_UNIXTIME() like this

SELECT * FROM table 
WHERE timestamp > FROM_UNIXTIME(1440586108)

Upvotes: 1

Related Questions