• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • Last Modified:

searching by the month only

Im try to find the right query to compare the month only of the last record, if the month is the current month do something


$today = date("m");

$obj = mysql_query ("SELECT DATE_FORMAT(printDate, '%m') AS f_date FROM prints ORDER BY printDate DESC LIMIT 0,1")
     or die ("Invalid query");
$oRow = mysql_fetch_object($obj);

I would think to put a WHERE is the query but doesnt sound like it would work properly

please help me out      
0
jtrudeau
Asked:
jtrudeau
  • 4
  • 2
1 Solution
 
sirbountyCommented:
Have you tried ...

"WHERE Month(Date)= " & $today & " "
0
 
jtrudeauAuthor Commented:
what is with the ampersand ?
0
 
jtrudeauAuthor Commented:
and month(date) will do what, what you sent me it appears that month() is a function but the argument date ????
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
sirbountyCommented:
you might also try month(now()) or month(now)

date is equivalent of today's date.
now would include the time, but month would strip out the month from both...
0
 
jtrudeauAuthor Commented:
not working :(
0
 
jtrudeauAuthor Commented:
yes! it does work, I have another question posted go check it out so I could accept this answer and accept your next answer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now