Results 1 to 4 of 4
  1. #1
    WW7350 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jul 2012
    Posts
    2

    Question Finding where a date lies in a date range and provide corresponding value


    Hey! I was wondering if someone could help me, been trying to figure this out for ages!!

    I have this table: (Table called Quantity)

    Component ID Purchase Date Quantity
    625656561 18/05/2012 2
    625656561 20/06/2012 5
    625656561 16/07/2012 8
    784891 18/01/2012 9



    and this table: (The valid To and valid From refers to when the prices are valid) (Table called Price)
    Component ID Valid To Valid From Price
    625656561 01/04/2012 19/05/2012 16
    625656561 19/06/2012 25/06/2012 26
    625656561 29/06/2012 01/07/2012 32
    784891 01/01/2012 31/01/2012 51
    784891 12/02/2012 19/02/2012 21


    So im trying to get a query that finds the corresponding price when the component was bought so I can times the price by the quantity.

    To get:

    Component ID Quantity Price
    625656561 2 16
    625656561 5 26
    625656561 8 32
    784891 9 51


    If anyone has an ideas that would be great THANKS!

  2. #2
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    625656561 8 32
    Wondering how you got above in result ?

    Just check if below gives some guidelines :

    Code:
    SELECT 
        Quantity.[Component ID], 
        Quantity.[Purchase Date], 
        Quantity.Quantity, 
        Price.[Component ID], 
        Price.[Valid To], 
        Price.[Valid From], 
        Price.Price
    FROM 
        Quantity 
        LEFT JOIN 
        Price 
        ON 
        (Quantity.[Component ID] = Price.[Component ID])
        AND 
        (
            Quantity.[Purchase Date] 
            BETWEEN 
            Price.[Valid From]  AND Price.[Valid To]
        );
    In addition, check out :

    http://www.baldyweb.com/OverLap.htm

    Thanks

  3. #3
    WW7350 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jul 2012
    Posts
    2
    Thanks recyan!! I had to change a few things, but it now works!!! Thanks very much!!!!

  4. #4
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Glad you got things working.

    Thanks

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

Similar Threads

  1. Date Range Report with Multiple Date Fields
    By StevenCV in forum Reports
    Replies: 13
    Last Post: 02-29-2012, 08:29 AM
  2. Specify A Date Range
    By jo15765 in forum Queries
    Replies: 17
    Last Post: 10-11-2011, 07:16 AM
  3. Date range Q
    By markjet in forum Queries
    Replies: 13
    Last Post: 07-18-2011, 01:00 PM
  4. Date range
    By eacollie in forum Queries
    Replies: 7
    Last Post: 06-05-2011, 03:38 PM
  5. Finding data between two date for any year
    By gemini2 in forum Access
    Replies: 4
    Last Post: 04-05-2006, 06:20 AM

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