Dotan Cohen wrote:
Hi all, I have a field in a mysql database v4.0.18 that contains a
linux timestamp. I have been googleing for a solution that would
return to me all the entries where the timestamp falls on, say a
wednesday, or between 2pm to 3pm. I am led to believe that it is
possible, but I have found no examples. Something like:
SELECT * from listings WHERE timestamp(day==wednesday)
or
SELECT * from listings WHERE timestamp(14:00 <= time <= 15:00)

If you're wanting to do queries like that regularly, you should set up columns containing the weekday and the hour and index them. For a one-shot, you can use a query something like

SELECT * FROM listings WHERE DATE_FORMAT(FROM_UNIXTIME(your_timestamp),'%W')) = 'Wednesday';

or

SELECT * FROM listings WHERE DATE_FORMAT(FROM_UNIXTIME(your_timestamp),'%H')) = '14';

but it won't be fast if the table is big.

--
Keith Ivey <[EMAIL PROTECTED]>
Smokefree DC
http://www.smokefreedc.org
Washington, DC

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to