Page 1 of 1

FROM_UNIXTIME is not returning full date range

Posted: Wed Sep 26, 2007 1:24 am
by Jsn7821

Code: Select all

$monthStart = mktime(0, 0, 0, date("m")-$count, 1, date("Y"));
$monthEnd = mktime(23, 59, 59, date("m")-$count+1, 0, date("Y"));
$query = mysql_query("SELECT * FROM `expenses` WHERE `date` > FROM_UNIXTIME($monthStart) AND `date` < FROM_UNIXTIME($monthEnd)");

The code should produce every result from the 1st to the last of the month, and it works fine EXCEPT: it doesn't return the 31st of August (last month) in the query. Any ideas?

Posted: Wed Sep 26, 2007 5:04 am
by Jsn7821
switched the > and < signs to >= and <=, and it works.

Doh. Solved.