user2029541
user2029541

Reputation: 666

ASP.Net Razor Days between dates

I am working on a project and I need to calculate the days between date account created and current date. my code works how ever it is not giving me just the days. This below code

@(item.AccountCreated.AddYears(1)-DateTime.Now)

gives me this result like this 330.06:53:24.6752284 when all I want to be displayed would be 330 is there a way to do this through Razor.

Issue now resolved by doing

@Convert.ToInt32(((item.AccountCreated.AddYears(1)-DateTime.Now).TotalDays))

Upvotes: 0

Views: 5860

Answers (1)

HOKBONG
HOKBONG

Reputation: 795

@((item.AccountCreated.AddYears(1)- DateTime.Now).TotalDays)

Upvotes: 5

Related Questions