MySQL query help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mainer82
    Senior Member
    • Apr 2003
    • 1285
    • 1.1.x

    MySQL query help

    Here's an overview of this table, it holds upcoming items by title and release date, there are x amount of items per month being released.

    What I need to do is query how many items are going to be available in the current month.

    Here's the query I've tried, but its not working:

    PHP Code:
    SELECT COUNT(*) AS num FROM upcoming WHERE w_date date_sub(current_month
  • Lats
    Senior Member
    • Mar 2002
    • 3671

    #2
    Try this...
    Code:
    SELECT 
        COUNT(*) 
    AS 
        num 
    FROM 
        upcoming 
    WHERE 
        DATE_FORMAT(w_date,'%Y-%m') = DATE_FORMAT(curdate,'%Y-%m')
    Lats...

    Comment

    • Mainer82
      Senior Member
      • Apr 2003
      • 1285
      • 1.1.x

      #3
      Hi, I tried that query. It returns results, but it returns all items in all months.

      I tried this: SELECT COUNT(*) AS num FROM upcoming WHERE DATE_FORMAT(w_date,'%Y-%m') = DATE_FORMAT(current_date,'%Y-%m');

      and it worked... thank you!
      Last edited by Mainer82; Mon 21 Aug '06, 3:15pm.

      Comment

      • Lats
        Senior Member
        • Mar 2002
        • 3671

        #4
        Ah, should have been curdate().

        Glad you got it working.
        Lats...

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...