Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Mysql dateadd query problem

Mysql dateadd query problem

Scheduled Pinned Locked Moved Database
databasehelpmysqlsysadminsales
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    archangel717
    wrote on last edited by
    #1

    All, I have been toying with this query for some time now to no avail. I need to run a retention report on sales that canceled within 30, 60, 90 days of the original sale date. My query is below. Could someone please help me in the right direction as to why it doesn't work? The error I get is below the query SELECT count(*) FROM db.orders where date_entered between "2007-08-01" and "2007-08-31" and cancel_date <= date_add('day', 30, date_entered) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '30, date_entered)' at line 2 Thank you very much!

    M 1 Reply Last reply
    0
    • A archangel717

      All, I have been toying with this query for some time now to no avail. I need to run a retention report on sales that canceled within 30, 60, 90 days of the original sale date. My query is below. Could someone please help me in the right direction as to why it doesn't work? The error I get is below the query SELECT count(*) FROM db.orders where date_entered between "2007-08-01" and "2007-08-31" and cancel_date <= date_add('day', 30, date_entered) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '30, date_entered)' at line 2 Thank you very much!

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      Reference for DATE_ADD in MySQL 6.0[^]. I think the correct syntax would be DATE_ADD(date_entered, INTERVAL 30 DAY). MySQL is not SQL Server and they do not necessarily use the same syntax for features that both implement. There is a common but very limited standard SQL syntax; many databases support most of SQL-92, but usually not all of it.

      DoEvents: Generating unexpected recursion since 1991

      A 1 Reply Last reply
      0
      • M Mike Dimmick

        Reference for DATE_ADD in MySQL 6.0[^]. I think the correct syntax would be DATE_ADD(date_entered, INTERVAL 30 DAY). MySQL is not SQL Server and they do not necessarily use the same syntax for features that both implement. There is a common but very limited standard SQL syntax; many databases support most of SQL-92, but usually not all of it.

        DoEvents: Generating unexpected recursion since 1991

        A Offline
        A Offline
        archangel717
        wrote on last edited by
        #3

        Thank you so much! That finally got it working. I knew there was a difference in mysql, but I just couldn't figure it out. Usually its the simple things that fix these problems. Thanks again mate!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups