Results 1 to 4 of 4
  1. #1
    didiomm is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2013
    Posts
    47

    Question Date query for last 6 months of data previous to current date

    Hi All:



    I have a query that I would like to return only data for the last six months previous to current date. I have tried the following:

    Code:
    SELECT HistoryDate.allemplid, HistoryDate.DateUpdatedFmt
    FROM HistoryDate WHERE HistoryDate.DateUpdatedFmt >= DATEADD("m", -6, Date);
    I get a popup box that says "date." When I enter today's date in mm/dd/yyyy format my query executes fine. But I am wanting the results without input. Is there a way for the code to execute without having to input the current date?

    Note the table I'm querying from doesn't have a column for today's date, or current timestamp, or anything like that. Do I need to add that to the table and alter my code to subtract 6 months from that value?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try including the function parentheses:

    DATEADD("m", -6, Date())
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    didiomm is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2013
    Posts
    47
    That did it! Thank you kindly!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 04-29-2016, 04:03 AM
  2. Replies: 3
    Last Post: 03-02-2016, 09:39 AM
  3. Replies: 3
    Last Post: 02-16-2016, 05:02 PM
  4. Replies: 2
    Last Post: 12-01-2014, 02:53 AM
  5. Get data - 3 months to Date
    By Shilabrow in forum Queries
    Replies: 3
    Last Post: 06-23-2014, 12:04 PM

Tags for this Thread

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