【发布时间】:2019-10-04 11:15:28
【问题描述】:
如果我从今天开始计算 5 天,则显示为 4 天。如果我将开始日期移回 1,它会显示 6
这是我目前拥有和工作的内容,除非我使用今天的日期作为开始日期。
private void DaysToShow()
{
//Find the difference in the days selected in the drop down menu so we can calculate
DateTime dtDateOnQuay = dtpDateOnQuay.Value;
DateTime dtDateLeft = dtpDateLeft.Value;
TimeSpan difference = dtDateLeft - dtDateOnQuay;
//As the days are inclusive and the above gets the days in between, add 1
m_iDaysRent = difference.Days + 1;
m_iDaysDetention = m_iDaysRent;
if (dtpDateReturned.Checked)
{
TimeSpan oDetentionDiff = dtpDateReturned.Value - dtpDateOnQuay.Value;
m_iDaysDetention = oDetentionDiff.Days + 1;
}
txtDaysOnQuay.Text = m_iDaysRent.ToString();
txtDaysDetention.Text = m_iDaysDetention.ToString();
}
【问题讨论】:
-
请编辑您的问题并在标签中指定您使用的编程语言
标签: c# date time timespan picker