C Sharp添加天数问题 [英] C Sharp Add Days Problem

查看:107
本文介绍了C Sharp添加天数问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的代码中,我使用AddDays运算符来添加天数。但我的要求是从 dsStartDate 中扣除天数。请有人帮帮我吧!

if(ddlMaintenPlan.SelectedItem.Text ==Weekly)

{

DateTime dtLastday = Convert.ToDateTime(dtpMaintenceEnd.Text.Trim());





DRLocal = DTLocal.NewRow();

DateTime dtS = Convert.ToDateTime(dtpMaintenceStart.Text.Trim());

DTLocal.Rows.Add(dtS);





while(dsStartDate< = dtLastday)

{

dsStartDate = dsStartDate.AddDays(7);

DRLocal = DTLocal.NewRow();

DTLocal.Rows.Add(dsStartDate);









DTLocal.Rows.Add(dsStartDate);

//}

}







}

In the following code I used AddDays operator to add days. But My requirement is to deduct days from dsStartDate. Can anyone help me, please!!!
if (ddlMaintenPlan.SelectedItem.Text == "Weekly")
{
DateTime dtLastday = Convert.ToDateTime(dtpMaintenceEnd.Text.Trim());


DRLocal = DTLocal.NewRow();
DateTime dtS = Convert.ToDateTime(dtpMaintenceStart.Text.Trim());
DTLocal.Rows.Add(dtS);


while (dsStartDate <= dtLastday)
{
dsStartDate = dsStartDate.AddDays(7);
DRLocal = DTLocal.NewRow();
DTLocal.Rows.Add(dsStartDate);




DTLocal.Rows.Add(dsStartDate);
//}
}



}

推荐答案

尝试:

Try:
dsStartDate = dsStartDate.AddDays(-7);


这篇关于C Sharp添加天数问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆