mysql select timestamps between a and b returning all or 0 timestamps -


tried this

select * table timestamp_field between 1330560000 , 1336170420 

and this

select * table timestamp_field >=1330560000 , timestamp_field<=1336170420 

both returning empty result set.

but this

select * table timestamp_field >= 1330560000 

returns rows

to make things more absurd

select * table timestamp_field <= 1336170420 

returns empty result set.

of course, there exists timestamp values before, between , after 1336170420=4.may 2012. , 1330560000=1.march 2012.

timestamp values ok, @ least phpmyadmin shows correct (human-readable) date-time values. created timestamps parsing strings, with

update table set timestamp_field = str_to_date(timestamp_string, '%d.%m.%y') 

guess i'm missing something, can't find what!?

mysql expects date literals, not integer ones:

select *   table  date(timestamp_field) between '2012-03-01' , '2012-05-04' 

to use integers (assuming seconds since unix epoch), first convert them using mysql's from_unixtime() function:

select *   table  timestamp_field between from_unixtime(1330560000)                            , from_unixtime(1336170420) 

or else use unix_timestamp() convert column unix representation:

select *   table  unix_timestamp(timestamp_field) between 1330560000 , 1336170420 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -