2 Replies Latest reply: May 21, 2013 4:52 AM by Geoff Blight RSS

    Days in selected months

    Geoff Blight

      Hello helpers...

       

      I have a month selector from which many can be selected and a year selector from which only one can be picked.

       

      For any given selection of year and month(s), I'd like to have the number of days for that selection. So I might select February, July and October 2012 and therefore want the number of days to be 29 + 31 + 31 = 91 days. This isn't a standard date diff as I don't want the period between selections.

       

      Any help will be much appreciated

      Cheers,

      Geoff.

        • Re: Days in selected months
          Gysbert Wassenaar

          You should probably just fix this in the script by adding a table with the numbers of days per month. If you have a date field too you could simply do a count of the date field.

           

          If all you have is a Year and Month field you can try:

          =ceil($(=concat(Monthend(MakeDate(Year,aggr(Month,Month),1))-Monthstart(MakeDate(Year,aggr(Month,Month),1)) ,'+')))

            • Re: Days in selected months
              Geoff Blight

              Thanks for the reply Gysbert. I've created a table of 'days in months' for all the months and years I need which is independent of my dataset and joined it in the set analysis.

               

              =sum({<Days.monthName = {"$(vSelectedMonths)"}, Days.yearNumber={'$(=Only(Year))'}>} Days.numDays)

               

              Top man!

               

              Cheers.