Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Pasi is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    38

    query with speciific dates

    datequery.docHI,

    I run a query each week for previous week. example" I have to run a query for today 12/30/13 and the query should run from 12/23/13 to 12/30/13. what can I put into expression to do this automatically so I don't have to open the query input the date and run it? I am trying to automate this so next week when I come back its already know that I need to run this query for past 7 days and just run the query.
    Thanks,
    Pasi.



    I have added attachment.

  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,652
    Try a criteria of:

    Between Date() - 7 And Date()
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Pasi is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    38
    Thanks Pbaldy but it did not work? any other suggestion?

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Perhaps something like:
    Between DateDiff("d",-7, Date()) and Date()
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Pasi is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    38
    Thanks BOb, Its not working? I know its something simple but I cant figure it out?

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by Pasi View Post
    Thanks BOb, Its not working? I know its something simple but I cant figure it out?
    "It's not working" doesn't really help us to help you.
    What result do you get?
    Can you show us the SQL of your query.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    Pasi is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    38
    When I run it it just hangs and nothing happens? when I give a range like: Between "20131201" And "20131208" executes fast and I get a result fast.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Is your field text rather than date/time? If so, why?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Pasi is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    38
    No its date Date field.doc no its date field see attached.
    Thanks!

  10. #10
    Pasi is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    38
    This is how I am doing it:

    [dbo_appointments1]![appt_date] Between Date() And Date()-"6"

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Your attachment doesn't indicate the data type of the field. Why do you have quotes around the 6? What's the SQL of the query?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    Pasi is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    38
    when I execute the query it puts quotes around number. not sure what you mean by sql of query?

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You can change the view when in design view to SQL view, which would look like

    SELECT...

    If it's putting quotes around the number, it's confused about the data type of the field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    Pasi is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    38
    OK I ma in Select view see attached.query view.doc

  15. #15
    Pasi is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    38
    Here is what I changed it to: DateAdd("d",-7,[appt_date])

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 12-02-2013, 03:46 PM
  2. Replies: 1
    Last Post: 10-18-2013, 03:14 PM
  3. IIf Query with dates
    By DelbyJones in forum Access
    Replies: 2
    Last Post: 08-16-2012, 02:33 PM
  4. Query input dates for range of dates in two fields
    By kagoodwin13 in forum Queries
    Replies: 3
    Last Post: 02-13-2012, 04:25 PM
  5. Run Query by dates
    By BorisGomel in forum Access
    Replies: 3
    Last Post: 07-21-2011, 03:54 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