Forum Discussion

nbaudry's avatar
nbaudry
Frequent Visitor
7 years ago

Number of months per year between 2 dates

Hello,

I would like to calcultate the number of months per year between 2 dates.
My table is like this:
ID---------------Year---------------Start date--------End date-----------------Result(my wish)
150-------------2018--------------18/08/2018-------30/06/2020--------------5
150-------------2019--------------18/08/2018-------30/06/2020--------------12
150-------------2020--------------18/08/2018-------30/06/2020--------------6

Thanks a lot for your help
N.

4 Replies

  • HotChilli's avatar
    HotChilli
    Icon for Community Champion rankCommunity Champion

    What is the logic here? Where do 5, 12, 6 come from?

    • nbaudry's avatar
      nbaudry
      Frequent Visitor

      The logic and the goal is to make a distribution of the load per month, the loads are filled per year.

      (I just realized a mistake in the column year ... sorry ... bad copy/paste)

      ID------Year----Start date--------End date--------Annual Load--------Result(my wish)
      150----2018----18/08/2018-------30/06/2020----100------------------5
      150----2019----18/08/2018-------30/06/2020----50-------------------12
      150--- 2020----18/08/2018-------30/06/2020----120------------------6

       

      5 months: Since the 18/08/2018 to 31/12/2018

      12, 6 ...

      • HotChilli's avatar
        HotChilli
        Icon for Community Champion rankCommunity Champion

        Still not clear...

        ID------Year----Start date--------End date--------Annual Load--------Result(my wish)
        150----2018----18/08/2018-------30/06/2020----100------------------5
        150----2019----18/08/2018-------30/06/2020----50-------------------12
        150--- 2020----18/08/2018-------30/06/2020----120------------------6

         

         

        5 months: Since the 18/08/2018 to 31/12/2018<----------------------- why 31/12/2018

        12, 6 ...  <------------- please explain these