5 Replies Latest reply: Mar 13, 2011 7:37 PM by Rakesh Mehta RSS

    How many days fall between 2 dates?

    Jason Michaelides

      Hi guys,

      I have a problem I just can't get my head around - hoping you can help [8-|]

      - At the top of my load script I set two variables - vMinDate and vMaxDate.
      - I have a table of Adverts with campaign StartDates and EndDates.

       


      LOAD
      Ad_ID,
      StartDate,
      EndDate
      FROM Ads.qvd(qvd);
      [/Code]
      I'd like to calculate, for each Advert, how many days of the campaign fall between vMinDate and vMaxDate (inclusive).
      E.g. - vMinDate = 01/01/2011; vMaxDate = 31/01/2011
      Ad_ID 1 - StartDate=10/01/2011; EndDate=20/01/2011; DaysInRange should = 11
      Ad_ID 2 - StartDate=20/12/2010; EndDate=02/01/2011; DaysInRange should = 2
      Ad_ID 3 - StartDate=10/11/2010; EndDate=20/12/2010; DaysInRange should = 0
      Ad_ID 4 - StartDate=05/02/2011; EndDate=20/02/2011; DaysInRange should = 0
      Ad_ID 5 - StartDate=20/01/2011; EndDate=20/02/2011; DaysInRange should = 12
      Ad_ID 6 - StartDate=01/12/2010; EndDate=01/03/2011; DaysInRange should = 31
      Any ideas!?
      Thank you,
      Jason
      </body>