@Model.Carta.ShippedDate.Value.ToString("HH") - @Model.Carta.CartaPDate.Value.ToString("HH") How i can subtract these dates?
Asked
Active
Viewed 94 times
-3
-
3How can you *what*? The verb "rest" makes no sense in this context. – Apr 17 '17 at 16:31
-
1Be more descriptive – P.K. Apr 17 '17 at 16:33
-
Are you asking how to format the dates? Because that's answered [here](http://stackoverflow.com/q/6001654/215552)... – Heretic Monkey Apr 17 '17 at 16:34
-
No. How i can subtract two dates? – Joheric Morel Guzman Apr 17 '17 at 16:38
-
2Start by not converting them to strings :) – Rufus L Apr 17 '17 at 17:04
2 Answers
1
Before you convert the dates to strings, you can subtract them which will give you a Timespan (https://msdn.microsoft.com/en-us/library/system.timespan(v=vs.110).aspx) You can then get total days like this:
(@Model.Carta.ShippedDate.Value - @Model.Carta.CartaPDate.Value).TotalDays

John Cornell
- 1,087
- 8
- 22