Home > Net >  Jiffy difference in month
Jiffy difference in month

Time:06-23

I use Jiffy for calculate the difference in between 2 date in month. But I don't the good result.

For end = 2/4/2023 and start = 1/4/2022 I have 12 months.

For end = 1/4/2023 and start = 1/4/2022 I have 11 months (error: expected 12).

Thanks,

num month = Jiffy(end).diff(Jiffy(start), Units.MONTH);

CodePudding user response:

Right now it is checking 12 at midnight to 12 at midnight of the end date which is 11 months 30 days. Now if the end date is one second greater than the correct date it should work. So a hackey solution is to add one day duration to the end date and check

end.add(duration(day:1))
  • Related