查找本周的第一个日期和最后一个日期 [英] Finding the first date and last date of the current week

查看:93
本文介绍了查找本周的第一个日期和最后一个日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想使用今天的日期找到星期的第一天以及本周的最后一天.从星期一到星期五

Hi
I want to find the first date of week aswell as the last day of the current week using todays date. From monday to friday

推荐答案

尝试:
DateTime today = DateTime.Now;
DateTime lastSunday = today.AddDays(-(int)today.DayOfWeek);

请注意,DayOfWeek运行的是Sun-Sat,0-6,因此,如果您运行周一至周日,您可能需要进行一些调整

Note that DayOfWeek runs Sun-Sat, 0 - 6 so you may want to tweak a little if you run Mon-Sun


ASP.NET的答案是:获取当前星期的开始和结束日期 [ ^ ]
ASP.NET has the answer: Get Current week starting and end date[^]


这篇关于查找本周的第一个日期和最后一个日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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