得到2个日期取决于当前日期 [英] to get 2 dates dependinng on present date
本文介绍了得到2个日期取决于当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我根据当前日期获得2个日期
假设如果当前日期是4月8日(位于上半年),我想获得2011年1月1日和2011年6月30日(上半年)
并且如果我现在的日期是2011年9月7日(位于下半年),我想获得两个日期2011年7月1日和2011年12月30日
pls help i want to get 2 dates depending on the present date
suppose if present date is 8 april(lies in first half year) i want to obtain 1 jan 2011 and 30 jun 2011 (first half year)
and if my present date is 7 sep 2011 (lies in second half year ) i want to obtain two dates 1 jul 2011 and 30 dec 2011
推荐答案
尝试:
DateTime start, end;
DateTime check = new DateTime(2011, 4, 6);
if (check < new DateTime(2011, 7, 1))
{
start = new DateTime(2011, 1, 1);
end = new DateTime(2011, 6, 30);
}
else
{
start = new DateTime(2011, 7, 1);
end = new DateTime(2011, 12, 31);
}
这篇关于得到2个日期取决于当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文