Overlapping dates logic

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim

    #1

    Overlapping dates logic

    Maybe I am making this too difficult; but I have the following issue:

    A record contains a price for a specific Start Date and End Date. If
    the user adds a new price, I need to make sure the Start Date doesn't
    overlap something that already exists. Meaning the new Start Date
    should not overlap the existing Start Date and End Date. Since I am
    new to VS2005 I thought perhaps there was a function to look at these
    dates... Your input is greatly appreciated!
  • Stephany Young

    #2
    Re: Overlapping dates logic

    Well let's just assume for a moment that all the existing date ranges for a
    specfic price are contiguous and that the end date for a given price cannot
    be earlier than the start date for that price.

    The business rule will be that the start date for a new price must be later
    than the end date for the most price with the latest end date.

    The process to do this is simply:

    Find the price that has the highest value for end date

    Ensure that the new start date is later than the end date for the price
    located

    There are may ways of finding the the price with the highest value for end
    date.

    One way would be to sort the price objects by end date descending and then
    the one you want is the first one.

    If you were using a SQL database then to find the highest value for end
    datae you would use a query something like:

    select max([end date]) from prices


    "Jim" <Jim@hot_mail.c omwrote in message
    news:0nbc53da8k 82uhs52folie1nh psd3pukp8@4ax.c om...
    Maybe I am making this too difficult; but I have the following issue:
    >
    A record contains a price for a specific Start Date and End Date. If
    the user adds a new price, I need to make sure the Start Date doesn't
    overlap something that already exists. Meaning the new Start Date
    should not overlap the existing Start Date and End Date. Since I am
    new to VS2005 I thought perhaps there was a function to look at these
    dates... Your input is greatly appreciated!

    Comment

    • jim

      #3
      Re: Overlapping dates logic

      It kinda makes sense, and I am using SQL Server 2005 as the backEnd, but do
      you have any coding examples, since I am new to VB/VS2005? Specifically,
      you mention finding a price that has the highest value for end date. An
      example would be greatly appreciated. I'm kinda VB stupid.


      "Stephany Young" <noone@localhos twrote in message
      news:e0xuYjmnHH A.3460@TK2MSFTN GP04.phx.gbl...
      Well let's just assume for a moment that all the existing date ranges for
      a specfic price are contiguous and that the end date for a given price
      cannot be earlier than the start date for that price.
      >
      The business rule will be that the start date for a new price must be
      later than the end date for the most price with the latest end date.
      >
      The process to do this is simply:
      >
      Find the price that has the highest value for end date
      >
      Ensure that the new start date is later than the end date for the price
      located
      >
      There are may ways of finding the the price with the highest value for end
      date.
      >
      One way would be to sort the price objects by end date descending and then
      the one you want is the first one.
      >
      If you were using a SQL database then to find the highest value for end
      datae you would use a query something like:
      >
      select max([end date]) from prices
      >
      >
      "Jim" <Jim@hot_mail.c omwrote in message
      news:0nbc53da8k 82uhs52folie1nh psd3pukp8@4ax.c om...
      >Maybe I am making this too difficult; but I have the following issue:
      >>
      >A record contains a price for a specific Start Date and End Date. If
      >the user adds a new price, I need to make sure the Start Date doesn't
      >overlap something that already exists. Meaning the new Start Date
      >should not overlap the existing Start Date and End Date. Since I am
      >new to VS2005 I thought perhaps there was a function to look at these
      >dates... Your input is greatly appreciated!
      >

      Comment

      • Stephany Young

        #4
        Re: Overlapping dates logic

        select top 1 * from prices order by [end date] desc


        "jim" <jimBob@msn.com wrote in message
        news:9tidnUrf9Z y0oMvbnZ2dnUVZ_ g-dnZ2d@giganews. com...
        It kinda makes sense, and I am using SQL Server 2005 as the backEnd, but
        do you have any coding examples, since I am new to VB/VS2005?
        Specifically, you mention finding a price that has the highest value for
        end date. An example would be greatly appreciated. I'm kinda VB stupid.
        >
        >
        "Stephany Young" <noone@localhos twrote in message
        news:e0xuYjmnHH A.3460@TK2MSFTN GP04.phx.gbl...
        >Well let's just assume for a moment that all the existing date ranges for
        >a specfic price are contiguous and that the end date for a given price
        >cannot be earlier than the start date for that price.
        >>
        >The business rule will be that the start date for a new price must be
        >later than the end date for the most price with the latest end date.
        >>
        >The process to do this is simply:
        >>
        > Find the price that has the highest value for end date
        >>
        > Ensure that the new start date is later than the end date for the price
        >located
        >>
        >There are may ways of finding the the price with the highest value for
        >end date.
        >>
        >One way would be to sort the price objects by end date descending and
        >then the one you want is the first one.
        >>
        >If you were using a SQL database then to find the highest value for end
        >datae you would use a query something like:
        >>
        > select max([end date]) from prices
        >>
        >>
        >"Jim" <Jim@hot_mail.c omwrote in message
        >news:0nbc53da8 k82uhs52folie1n hpsd3pukp8@4ax. com...
        >>Maybe I am making this too difficult; but I have the following issue:
        >>>
        >>A record contains a price for a specific Start Date and End Date. If
        >>the user adds a new price, I need to make sure the Start Date doesn't
        >>overlap something that already exists. Meaning the new Start Date
        >>should not overlap the existing Start Date and End Date. Since I am
        >>new to VS2005 I thought perhaps there was a function to look at these
        >>dates... Your input is greatly appreciated!
        >>
        >
        >

        Comment

        • jim

          #5
          Re: Overlapping dates logic

          Thanks Stephany. I'll give it a shot! Not sure what TOP 1 returns, but
          I'll figure it out.

          "Stephany Young" <noone@localhos twrote in message
          news:OGz7SEnnHH A.4516@TK2MSFTN GP05.phx.gbl...
          select top 1 * from prices order by [end date] desc
          >
          >
          "jim" <jimBob@msn.com wrote in message
          news:9tidnUrf9Z y0oMvbnZ2dnUVZ_ g-dnZ2d@giganews. com...
          >It kinda makes sense, and I am using SQL Server 2005 as the backEnd, but
          >do you have any coding examples, since I am new to VB/VS2005?
          >Specifically , you mention finding a price that has the highest value for
          >end date. An example would be greatly appreciated. I'm kinda VB stupid.
          >>
          >>
          >"Stephany Young" <noone@localhos twrote in message
          >news:e0xuYjmnH HA.3460@TK2MSFT NGP04.phx.gbl.. .
          >>Well let's just assume for a moment that all the existing date ranges
          >>for a specfic price are contiguous and that the end date for a given
          >>price cannot be earlier than the start date for that price.
          >>>
          >>The business rule will be that the start date for a new price must be
          >>later than the end date for the most price with the latest end date.
          >>>
          >>The process to do this is simply:
          >>>
          >> Find the price that has the highest value for end date
          >>>
          >> Ensure that the new start date is later than the end date for the price
          >>located
          >>>
          >>There are may ways of finding the the price with the highest value for
          >>end date.
          >>>
          >>One way would be to sort the price objects by end date descending and
          >>then the one you want is the first one.
          >>>
          >>If you were using a SQL database then to find the highest value for end
          >>datae you would use a query something like:
          >>>
          >> select max([end date]) from prices
          >>>
          >>>
          >>"Jim" <Jim@hot_mail.c omwrote in message
          >>news:0nbc53da 8k82uhs52folie1 nhpsd3pukp8@4ax .com...
          >>>Maybe I am making this too difficult; but I have the following issue:
          >>>>
          >>>A record contains a price for a specific Start Date and End Date. If
          >>>the user adds a new price, I need to make sure the Start Date doesn't
          >>>overlap something that already exists. Meaning the new Start Date
          >>>should not overlap the existing Start Date and End Date. Since I am
          >>>new to VS2005 I thought perhaps there was a function to look at these
          >>>dates... Your input is greatly appreciated!
          >>>
          >>
          >>
          >

          Comment

          Working...