Get months / years between two dates.

bauss jj_1337 at live.dk
Wed May 6 20:02:20 UTC 2020


On Wednesday, 6 May 2020 at 19:58:59 UTC, Adam D. Ruppe wrote:
> On Wednesday, 6 May 2020 at 19:51:01 UTC, bauss wrote:
>> How will I get the months or years between the two dates?
>
> What's the length of a month or a year? That's the tricky part 
> - they have variable lengths. So a difference of one month is 
> not super precise.
>
> You could probably just do days / 365 or days / 30 to get a 
> reasonable approximation but that's why the library doesn't 
> give you an easy pre-made answer.

I actually found something. I can't rely on "approximation" 
unfortunately.

DateTime apparently has a "diffMonths" function that can be used.


More information about the Digitalmars-d-learn mailing list