Jump to content


Photo

How do I query a datetime for the current month?


  • Please log in to reply
1 reply to this topic

#1 Catp00p

Catp00p
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 18 October 2003 - 06:39 PM

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())";


#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 18 October 2003 - 07:04 PM

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
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users