Difference between a date in dd.mm.yyyy and now - strange behavior

I have a date in a dd.mm.yyyy format i want to know how many days have passed since that date.
What i did is

DateTime.ParseExact("09.10.2018", "dd.mm.yyyy", System.Globalization.CultureInfo.InvariantCulture) - DateTime.ParseExact(Date.Now.Tostring("dd.mm.yyyy"), "dd.mm.yyyy", system.Globalization.CultureInfo.InvariantCulture)

What I have received is: 6.00:06:00 which is obviously false as since 9th of october we had roughly speaking ~60 days. How to fix that ? Why is this happening?

Are there any other better methods to calculate difference between today and some date in a past?

dd.mm.yyyy is different than dd.MM.yyyyy
mm => minutes
MM => Month
Change the date format to represent “dd.MM.yyyy”, it will work.
And the standard way to calculate the difference is, Date1.Subtract(Date2) which returns the difference.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.