FROM_UNIXTIME is not returning full date range

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Jsn7821
Forum Newbie
Posts: 5
Joined: Fri Dec 05, 2003 6:08 pm

FROM_UNIXTIME is not returning full date range

Post 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?
Jsn7821
Forum Newbie
Posts: 5
Joined: Fri Dec 05, 2003 6:08 pm

Post by Jsn7821 »

switched the > and < signs to >= and <=, and it works.

Doh. Solved.
Post Reply