I want to calculate no of days remaining for particular day from today onwards. How to calculate difference between 2 dates in C#??
Asked
Active
Viewed 1,728 times
1
-
http://stackoverflow.com/questions/1170257/calculate-days-remaining-to-a-birthday – JsonStatham Jun 28 '13 at 09:02
-
1`DateDiff("d",Day(Date()),#28/10/2013#)` returns 41547 because today is the 28th day of the month so `Day(Date())` returns 28 and `CDate(28)` is `1900-01-27`. Therefore, `DateDiff()` is counting the number of days between `1900-01-27` and `2013-10-28`. If you get rid of the `Day()` part then things should work better. – Gord Thompson Jun 28 '13 at 09:49
2 Answers
3
(Note: This answer was written when the question was worded very differently)
Assuming your dates are DateTime
or DateTimeOffset
:
TimeSpan delta = date1 - date2

Sebastian Negraszus
- 11,915
- 7
- 43
- 70