PDA

View Full Version : mysql select


testbot
12-09-2009, 01:48 PM
what is the lastpost in thread table format?

i need to select threads from the past 48 hours and where the lastpost is > 7 days

i'm not sure the best way to do this. i have the following so far.


$check=$vbulletin->db->query_read("
SELECT * from `" . TABLE_PREFIX . "thread`
WHERE `forumid` IN($from)
AND `lastpost` <= (TIMENOW - 7 DAYS)
AND `dateline` <= (TIMENOW - 2 days)");


you can see the last two lines of the sql query need to be corrected.

thanks for your help!

Lynne
12-09-2009, 02:15 PM
The lastpost and dateline are in unix time (http://en.wikipedia.org/wiki/Unix_time), so you want to convert your "7 days" and "2 days" into seconds.

testbot
12-09-2009, 02:16 PM
i think i got it

i'll try

<= '" . (TIMENOW - ($days * 86400)) . "'

Lynne
12-09-2009, 02:23 PM
That should work. :)