Results 1 to 3 of 3
  1. #1
    TheSpecialist is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2015
    Location
    Georgia
    Posts
    47

    Search by Number and i want to see the numbers that came two days before and after

    Hi group,

    Below is my sql so far. I want to be able for this sql search 2 days before and 1 day after. For instance, if I enter 5 5 5 and that number came on 10/31/2006. I want to see the numbers that came on 11/1/2006 and 11/2/ 2006 and 10/30/2006.





    SELECT YourTable.YourNumber, YourTable.YourTable, YourTable.YourDate, MoonPhaseTable.MoonPhaseTable, MoonPhaseTable.YourNumber
    FROM YourTable INNER JOIN MoonPhaseTable ON YourTable.YourDate = MoonPhaseTable.YourDate
    WHERE (((YourTable.YourNumber)=[Enter Number]));

    Please help me and thank you

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    If your query is saved as qsFindNum
    then open the 2nd query qsFindNumPlusDays
    where Q2 looks at the date from Q1 and the days around it:

    qsFindNum=
    SELECT tClients.ClientID, tClients.FirstN, tClients.LastN, tClients.Birth AS YourDate, DateAdd("d",-2,[Birth]) AS LowDate, DateAdd("d",1,[Birth]) AS HiDate
    FROM tClients
    WHERE (((tClients.ClientID)=15));


    'the above pulls the 1 client and date, and the 2 days before, and 1 date after
    'then run Q2 below to get all the results inside the dates given above

    qsFindNumPlusDays=
    SELECT tClients.ClientID, tClients.FirstN, tClients.LastN, tClients.Birth
    FROM tClients, qsFindNum
    WHERE (((tClients.Birth) Between [qsFindNum].[LowDate] And [qsFindNum].[HiDate]));

  3. #3
    TheSpecialist is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2015
    Location
    Georgia
    Posts
    47
    Hi RanMan,

    I am still really new to SQL. I put the information I posted from SQL however I put it in the criteria design view but I am having difficulties. I not really sure what the above information you sent to me. Thank you so much for responding.

    Erika

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

Similar Threads

  1. difference in dates: Number of days
    By akapag22 in forum Queries
    Replies: 2
    Last Post: 06-23-2015, 08:39 PM
  2. Change number to Year, Month, Days
    By trident in forum Forms
    Replies: 10
    Last Post: 05-25-2015, 08:16 AM
  3. Count number of days
    By ramindya in forum Queries
    Replies: 1
    Last Post: 02-22-2012, 04:47 PM
  4. Number of Days between visits
    By gstullo in forum Queries
    Replies: 5
    Last Post: 12-19-2011, 10:08 AM
  5. number of days query
    By osuprog in forum Queries
    Replies: 15
    Last Post: 09-17-2010, 01:15 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