+ Reply to Thread
Results 1 to 5 of 5

Isolate the datalines based on a given date within a date interval

  1. #1
    Registered User
    Join Date
    11-03-2014
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2013
    Posts
    18

    Isolate the datalines based on a given date within a date interval

    Hi All

    I have the following dataset:

    Itemnumber
    Start date
    End date
    Pricelist name
    Price

    My challenge is to write a Query, that will give me the Price on any given date.
    I would like the Query to ask me what date the returned Price should be based upon. For example i'll punch in 20170215 and the Query will automatically return the Price(s) where this date falls within the date interval.

    I have attached a data example to illustrate my point...

    Hope to hear and lean from the wiser...

    Jesper
    Attached Files Attached Files

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Isolate the datalines based on a given date within a date interval

    This should do it... Assuming your Database table is named Table1

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    11-03-2014
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2013
    Posts
    18

    Re: Isolate the datalines based on a given date within a date interval

    Hi Mike

    This doesn't quite work as far as I can see...

    The date I punch in should be decisive for what Price is returned. So, if I have a Price of 5$ valid in the period 20161001 to 20171231 and another Price, 6$ valid from 20160901 to 20160930, and I punch in 20160914 then the Query must identify the right Price based on the date interval - in this case the punched date falls into the latter interval (20160901-20160930) and the Price valid on the date 20160914 is Thus 6$...

    Does that make any sense?

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: Isolate the datalines based on a given date within a date interval

    Does this work for you?
    PHP Code: 
    SELECT table1.Itemnumbertable1.[Start date], table1.Pricelistnametable1.Pricetable1.[End date]
    FROM table1
    WHERE 
    (((table1.[Start date])<[Search Date]) AND ((table1.[End date])>[Search Date])); 
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Registered User
    Join Date
    11-03-2014
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2013
    Posts
    18

    Re: Isolate the datalines based on a given date within a date interval

    Yes, that's what I needed!

    Thanks very much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 12-01-2015, 02:36 PM
  2. Highlight Rows Based on Date Range Using Static Date and Current Date
    By SaraStravers in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-23-2015, 07:38 PM
  3. Returning Rows of Data based on a date interval
    By JonesTom in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-16-2015, 05:34 PM
  4. Replies: 4
    Last Post: 11-26-2014, 09:22 PM
  5. [SOLVED] Index Match Based on One Date Criteria, Table Contains Beginning Date and End Date
    By jcox1953 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-09-2014, 02:41 PM
  6. [SOLVED] Date Interval Formula
    By Hudson in forum Excel General
    Replies: 9
    Last Post: 08-17-2012, 03:55 PM
  7. Date Interval
    By shers in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-21-2008, 02:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1