Hi...
I've searched through the forums for a resolution to this problem, and haven't had any luck with the examples I've found so far.
What I am needing to do is get the current month from a database field that contains timestamp data in UNIX Timestamp format. I need to construct a query that get's the current month from the timestamp, so I can get the number of rows that have been entered in the current month. The current sql query I'm working with is this :
$mnthchk = date('U');
$mnth = date('F', $mnthchk);
$sql = "SELECT data_id, FROM_UNIXTIME(data_timestamp, '%M') FROM data WHERE data_timestamp = '$mnth'";
$result = @mysql_query($sql, $connection) or die(mysql_error());
$nrows = mysql_num_rows($result);
So far, I've not had any luck. I've tried to encapsulate the FROM_UNIXTIME inside a MONTH (as in MONTH(FROM_UNIXTIME(data_timestamp), '%M') and MONTH(FROM_UNIXTIME(data_timestamp, '%M')) ) without any success. The data_timestamp field is an INT(15) field in the database.
Am I not going about this query construct correctly? Obviously I'm not getting the query correct, but is there perhaps another way to accomplish this?