Number of months in the table

Hi,

I download the xlsx table with data from maximal last 12 months (eg. from 11.2018 to 10.2019 - 12 months). Of course it is possible that period of data will be shorter (eg. 02.2019 to 10.2019 - 9 months). To my analisys I have to count number of months in the table (to calculate average numbers of data for one month). Format date is XXXX-MM-DD.

Do you have any idea how to do it?

Maybe from the latest date subtract the earliest date and the result divide by 30 days?

Hi @Krzysztof

Try DateTime.ParseExact(row(“DateColumn1”).ToString,“dd.MM.yyyy”,system.globalisation.cultureinfo.invariantculture,“yyyy-MM-DD”)- DateTime.ParseExact(row(“DateColumn2”).ToString,“dd.MM.yyyy”,system.globalisation.cultureinfo.invariantculture,“yyyy-MM-DD”)/30

or use Cdate function to compare the values

Thanks
Ashwin S

Thank you for your answer.
What does “DateColumn1” and “DateColumn2” mean? I have one column with date.
Eg.
2019-02-11
2019-02-15
2019-03-30
2019-04-21

I understand that the best solution is to count number of days and divide by 30, yes?

I think that it is also possible to use counter of months and check if -MM- contains from 01 to 12. If yes, counter of months +1.