Date Range Check and Availability RRS feed

  • Question

  • Hi


    I have two 3 records like following and i am trying to change the start date and end date of the one if the record, before update i would like to check the availability.Please let me know how can i do this

    So for example my new start date  is 15/04/2010 and end date is 30/04/2010  how can check the availability

    It's similar to the booking

    please let me know

    Record           startdate                       enddate

      1                  14/04/2010                   30/04/210

       2                   07/04/2010                   13/04/2010






    Friday, April 16, 2010 1:22 AM


  • Are you allowing overlaps or not? If not, I used just yesterday the technique described by Erik here


    In other words, you can use this query
    if exists (SELECT 1 FROM Activity WHERE StartDtm < @ToTime -- the activity starts before the end of the date range
    AND EndDtm >= @FromTime -- and ends after the start of the date range)
    -- You can not update

    Premature optimization is the root of all evil in programming. (c) by Donald Knuth

    Naomi Nosonovsky, Sr. Programmer-Analyst

    My blog
    • Marked as answer by KJian_ Thursday, April 22, 2010 7:24 AM
    Friday, April 16, 2010 1:29 AM