Results 1 to 2 of 2
  1. #1
    kagoodwin13 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Feb 2012
    Posts
    181

    DateAdd with days added as variable from table value

    I am trying to change a query to have DateAdd call a variable number of days into the Between function.

    Currently the code is:
    Code:
    SELECT DISTINCTROW Home.HOEFF
    FROM Home
    WHERE  (Home.HOEFF) Between Date() And  DateAdd("d",+30,Date());
    The query currently finds all records where HOEFF is between Today and 30 days from Today.



    I would like to change the end date of the Between function to a variable. That way I can set a variable number of days for this query to return values. The use case is to look between Today and 30 Days for some users, and Today and 45 Days for other users.

    I am trying to use the query:
    Code:
    SELECT DISTINCTROW Home.HOEFF
    FROM Home LEFT JOIN tblCommunicationAdvancedOptions ON Home.Location = tblCommunicationAdvancedOptions.Location
    WHERE ((Home.HOEFF) Between Date() And DateAdd("d",Val([tblCommunicationAdvancedOptions].[RenewalNotificationDays]),Date());
    But I am getting a syntax error in the WHERE statement.

    Can anyone help me figure this out?

    Thanks!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Odd number of parens. Can remove the first one after WHERE. Actually, the first 3 are not necessary.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 20
    Last Post: 01-13-2015, 02:23 PM
  2. Replies: 9
    Last Post: 10-25-2014, 04:09 PM
  3. Replies: 1
    Last Post: 10-04-2012, 11:28 PM
  4. Blank Record Being Added to Table
    By Andrew in forum Programming
    Replies: 8
    Last Post: 12-22-2011, 04:41 AM
  5. Replies: 3
    Last Post: 01-21-2010, 08:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums