how can i do this?
select * From table_name Where date = currentmonth
when date is a double and i insert it like so date = date("U")
so i want to select the month of date("U") for the current month
how to select current month
To confirm, the date is set as a Unix timestamp, correct? I had a plan based around a date datatype, but was forced to adjust when I re-read the problem.
For Unix timestamps, this was my plan.
$time = time();
/*
Using $time for generating time strings for the one-in-a-zillion
chance that someone runs this at the precise stroke of midnight.
*/
$year = date('Y',$time);
$month = date('F',$time);
#Current Month
$day_count = date('t',$time);
#Count of the days in current month.
$test = $month.' '.$day_count.' 23:59:59 '.' '.$year;
#Debugging
$month_start = strtotime($year.' '.$month);
#Unix timestamp of the start of a month.
$month_end = strtotime($test);
#Unix timestamp of the final second of a month.
echo ";$month_start;$month_end;$test";
#Test output
You can then run your query for entries that are within the bounds of those two numbers.
... WHERE date >= '.$month_start.' AND date <= '.$month_end.'
In the event that I misread when I re-read, my idea for the date datatype was to use the LIKE operator with a wildcard for the day value.
$cur_month = date('Y-m-');
mysql_query('SELECT * FROM table WHERE date LIKE '.$cur_month.'%;');
you can skip the php and do it with mysql
select * From table_name Where MONTH(date) = MONTH(NOW())
14 days later
Dagon is given a logical answers. Go with it.