searching by the month only

Posted on 2005-05-13
Last Modified: 2010-04-17
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      
Question by:jtrudeau
    LVL 67

    Expert Comment

    Have you tried ...

    "WHERE Month(Date)= " & $today & " "

    Author Comment

    what is with the ampersand ?

    Author Comment

    and month(date) will do what, what you sent me it appears that month() is a function but the argument date ????
    LVL 67

    Accepted Solution

    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...

    Author Comment

    not working :(

    Author Comment

    yes! it does work, I have another question posted go check it out so I could accept this answer and accept your next answer

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now