如何从剃须刀中显示两个日期之间的天数

How to display the number of days between two dates in view from within razor

我正在尝试显示文档的送达日期,但想从视图而不是控制器中计算此数字。这是我的代码:

@foreach (var item in Model.queue_items)
        {
            <tr class="row">
                <td>@Html.Label("", (string)item.report_name)</td>
                <td>@Html.Label("", DateTime.Now.Subtract(item.expires_date).Days.ToString())</td>
                <td>@Html.Label("", (string)item.state)</td>
                <td><a href="@Url.Action("ReportProcessQueue", "Reporting", new { ReportId = item.report_id })" alt="A Link"><span class="glyphicon glyphicon-folder-open" id="btnOpen" data-edit-id="OpenDocument" title="@Text.Get(Text.eTextType.Button, "Open")"></span></a></td>
            </tr>
        }

这是给我号码“1408”。不知道我做错了什么。有什么想法吗?

我的原始代码实际上是正确的,我没有查看文档的创建日期,它是 1408 天前创建的

@foreach (var item in Model.queue_items)
    {
        <tr class="row">
            <td>@Html.Label("", (string)item.report_name)</td>
            <td>@Html.Label("", DateTime.Now.Subtract(item.expires_date).Days.ToString())</td>
            <td>@Html.Label("", (string)item.state)</td>
            <td><a href="@Url.Action("ReportProcessQueue", "Reporting", new { ReportId = item.report_id })" alt="A Link"><span class="glyphicon glyphicon-folder-open" id="btnOpen" data-edit-id="OpenDocument" title="@Text.Get(Text.eTextType.Button, "Open")"></span></a></td>
        </tr>
    }

希望这对某人有所帮助。