PDA

View Full Version : displaying data by month


fizzik
05-27-2007, 11:57 PM
the title is a bit iffy, my apologies.

i am in the process of making a stats page for an awards system. i can retrieve the required data from the database, however im stuck as to how i should write a query to retrieve data from only the current month. I have used unix timestamp to record when the award was given?

any help would be most appreciated.

thanks

Kungfu
05-28-2007, 03:30 PM
$month = date('m');
$year = date('Y');
$month2 = ($month<=12)?($month+1):1;
$year2 = ($month<=12)?$year:($year+1);

dateline >= ".mktime(0, 0, 0, $month , 1, $year)." AND dateline <= ".mktime(0, 0, -1, $month2, 1, $year2)

Eikinskjaldi
05-30-2007, 12:38 AM
alternatively...

month(from_unixtime(dateline)) = month(now()) and year(from_unixtime(dateline)) = year(now())