I have a problem with query where the conditions are related to TIMESTAMP column. So I have a table named table1 which has two columns start_time and end_time. Both of them store TIMESTAMP. I want to query my databse for a particular rows where end_time is higher than given timestamp value and lower than given timestamp value. Basically I want to get all the rows where end_time is between given TIMESTAMP range.
I have found that in my case following query works:
SELECT * FROM table1
WHERE UNIX_TIMESTAMP(end_time) >= FROM_UNIXTIME('2015-11-30 20:14:00')
AND UNIX_TIMESTAMP(end_time) <= FROM_UNIXTIME('2015-11-30 20:14:05')
But it is not what I want to. I want to give TIMESTAMP value instead of DATE.
What is also strange is that this query returns values that have end_time of earlier date than given timestamp:
SELECT * FROM table1 WHERE end_time > FROM_UNIXTIME( '2015-11-30 20:20:05' )
Query above returns rows where end_timestamp is 2015-11-30 20:18:05
I feel that I am missing something here. Should I use INT instead of TIMESTAMP for my end_time? I believe that the following query should return expected values but it gives me nothing:
SELECT * FROM table1
WHERE end_time >= FROM_UNIXTIME( 1448914740 )
AND end_time <= FROM_UNIXTIME( 1448914810 )