-3

@Model.Carta.ShippedDate.Value.ToString("HH")  - @Model.Carta.CartaPDate.Value.ToString("HH") How i can subtract these dates?

2 Answers2

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
1

I believe this is what you are looking for.

Assuming EndDate and StartDate are a type of DateTime:

(EndDate - StartDate).TotalDays
Community
  • 1
  • 1
Unknown
  • 769
  • 2
  • 7
  • 17