Syntax Error in Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MadSma
    New Member
    • Sep 2010
    • 13

    Syntax Error in Query

    on the desingh view of my qwery that shows endindDate(end) and description(des c)
    i added the following:

    Code:
    exp1: DateDiff( 'd',Date(),[end])
    so that each time the query runs to autocalculate how many days left from the end date until today

    my problem is that i get invalid syntax erro and it marks my first comma

    at first i thought it was the current date naming and i have also tried todaysdate,curD ate but none of them works

    can anyone help???

    is this the right way to produce and update remaining days data

    thatnk you
  • Narender Sagar
    New Member
    • Jul 2011
    • 189

    #2
    I checked your query in my database, and didn't find any problem in it. It is working fine.

    Comment

    • nico5038
      Recognized Expert Specialist
      • Nov 2006
      • 3080

      #3
      Try to use a double quote (") instead of (') around the "d"
      And in the graphical query editor use the separator from your Regional Settings (Could be a ";"). Otherwise switch to SQL (text) mode and than the comma can be used.


      Nic;o)
      Last edited by nico5038; Sep 26 '11, 05:53 AM.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32661

        #4
        Your post is quite sloppy, which normally isn't too much of a problem, but it makes it hard to be sure what is an error in your code and what is simply sloppiness when posting (See When Posting (VBA or SQL) Code).

        Taking your posted code as an exact copy of the code that's failing I would suggest removing the space before 'd'. This could conceivably cause a problem though I would expect it to be fixed for you automatically, or even get disregarded happily by the SQL processor.

        The single-quotes (') are actually the correct usage for 'd'. Double-quotes (") can be used, and would work equally well, but are less correct in these circumstances.

        The regional settings are definitely something else to look into. The most likely cause of the problem if I guess correctly.

        Comment

        • MadSma
          New Member
          • Sep 2010
          • 13

          #5
          yeah sorry for the crappy code...forgive the newbie pls

          resetting the regional setting did it for me

          thank you all for your responses there where all very handy first of all i wasn't sure if the codes logic was correct when i learn from you guys that the logic was correct i was looking for the problem elsewhere and NeoPa gave excellent advice

          thank you all

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32661

            #6
            Very pleased to be of help MadSma (Interesting ID BTW). In view of the fact that the answer to the fundamental question came originally from Nico, I would suggest post #3 as a good candidate for Best Answer.

            Comment

            Working...