Announcement

Collapse
No announcement yet.

MySQL query help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

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

    Comment


    • #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 21st Aug '06, 3:15pm.

      Comment


      • #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...
        X