locked
DateAdd -> The expression you entered contains invalid syntax RRS feed

  • Question

  • Hi,

    I have a problem with the DateAdd function to use in a query. I get alway the expression invalid syntax.

    The problem is in the 3rd parameter i think, but i 'am not shure. i tryed this versions, but i get always the error

    DateAdd('m', -12, Date())

    DateAdd('m', -12, #08/01/2017#)

    Access 365 shows the message and mark the 3rd parameter. Did anyone knows why this function not work?

    Andreas

    Monday, September 11, 2017 8:29 AM

All replies

  • Hi. Just a guess but have tried using a double quote? For example, DateAdd("m", -12, Date())
    Monday, September 11, 2017 1:23 PM
  • Hi,

    just another guess: If this is the expression in the query grid (<> SQL view) and given your name and accent ;-) could it be that your regional settings are not American? In this case your e.g. somehow European (Windows) list separator may be ; instead of , and you could try:

    DateAdd("m"; -12; Date())


    Karl
    http://www.AccessDevCon.com
    http://www.donkarl.com


    • Edited by Karl DonaubauerMVP Monday, September 11, 2017 2:16 PM as always fixing the sig
    Monday, September 11, 2017 2:15 PM
  • Hello,

    You could go to Design View of the query and use Expression Builder to build the criteria. It would show your current format based on your format settings.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, September 12, 2017 6:52 AM
  • Hi Thoril,

    Has your issue been resolved? If not, could you share us how you use this function.

    I made a test with below query in Access 2016 Query SQL View, it shows the result correctly.

    SELECT DateAdd('m', -12, Date()), DateAdd('m', -12, #08/01/2017#)

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 18, 2017 6:28 AM