添加7天为期6天 [英] add 7 days adds 6 days why
本文介绍了添加7天为期6天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
int year = DateTime.Now.Year;
int month = DateTime.Now.Month;
int days = DateTime.Now.Day;
DateTime StartDate = new DateTime(year,month,days);
DateTime EndDate = StartDate.AddDays(7);
i我现在正在加入7天的日期时间。
从03-24到03-31进行重新布局但它应该是04-01?
为什么?
i am adding 7 days to datetime now.
its gets when debbuging from 03-24 until 03-31 but it should be 04-01?
why?
推荐答案
如果查看日历,下周星期二是3月31日。不是4月1日。
if you look at the calendar, next week tuesday is 31 march. not 1st of april.
你错过了什么......
首先!为什么要重新创建而不是使用它....
You missed something here...
First! Why re-create Now instead of using it....
DateTime StartDate = DateTime.Now;
秒!让我们一起计算......
Second! Let count together...
24 + 1 = 25
25 + 1 = 26
26 + 1 = 27
27 + 1 = 28
28 + 1 = 29
29 + 1 = 30
30 + 1 = 31
现在确实如此! 7行!!!
Now that's exactly! 7 lines!!!
嗯。
Um.
M T W Th Fr Sa Su
23 24 25 26 27 28 29
30 31 01 02 03 04 05
24日加7天== 3月31日星期二......
24th plus 7 days == Tuesday 31st March...
这篇关于添加7天为期6天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文