Well, you could use the FROM_UNIXTIME() function to convert it into a datetime MySQL understands.

SELECT
   COUNT(*) AS score
FROM downloads
WHERE
   date_add(FROM_UNIXTIME(dateline), interval 1 hour) >= now()
GROUP BY filename
ORDER BY score DESC

But, considering what you're doing, it would probably be better if you just skipped all the MySQL date functions and just used UNIX_TIMESTAMP() instead.

SELECT
   COUNT(*) AS score
FROM downloads
WHERE
   UNIX_TIMESTAMP() - dateline <= 3600
GROUP BY filename
ORDER BY score DESC


I haven't tested these, but you should be looking at the manul anyway.

Chris


FROM_UNIXTIME():
http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html#id2724743

UNIX_TIMESTAMP():
http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html#id2726862


Sebastian wrote:

i have this query:

SELECT COUNT(*) AS score FROM downloads WHERE date_add(dateline,
interval 1 hour) >= now() GROUP BY filename ORDER BY score DESC

unfortunately for other reasons i had to change `dateline` to unix timestamp so this query is no longer able to run as intended. can anyone help with a work around?
btw, i am using php to run queries if that helps find a solution.








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

Reply via email to