Jump to content

Archived

This topic is now archived and is closed to further replies.

Catp00p

How do I query a datetime for the current month?

Recommended Posts

I have tried this but it is returning value of 0... postdate is a datetime field and there are many records in the current month.

 

$query2 = "SELECT count(*) FROM news WHERE author = \'$newsPosterName\' AND posttime = MONTH(NOW())";

Share this post


Link to post
Share on other sites

Almost :)

 

[php:1:135268d700]<?php

$query2 = \"SELECT count(*) FROM news WHERE author = \'$newsPosterName\' AND MONTH(posttime) = MONTH(NOW())\";

?>[/php:1:135268d700]

 

hth

 

EDIT : PS you might want to check the years are the same too

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.