I want to get the difference between two DateTime objects as a DateTime and not as a Period or something like that. How can I do that ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t, because it doesn’t make sense.
What’s the difference between September 25th 2012 and December 25th 2012? It’s two months, or ~60 days (I haven’t checked exactly) – but it certainly isn’t “February 20th 1970” or anything like that.
If you find yourself wanting the difference as a
DateTime, it means something in your design is messed up, and you should revisit it. If you have trouble working out exactly where the problem is, you can give us more information and we may be able to identify where the types are wrong, but fundamentally what you’re asking for won’t work.