码迷,mamicode.com
首页 > 其他好文 > 详细

WPF 本周、本月、本季、本年的第一天与最后一天取法

时间:2014-05-10 00:38:52      阅读:343      评论:0      收藏:0      [点我收藏+]

标签:tar   c   int   string   art   a   

         lblWeekStart.Content = DateTime.Now.AddDays(Convert.ToDouble((0 - Convert.ToInt16(DateTime.Now.DayOfWeek)))).ToShortDateString();
          lblWeekEnd.Content = DateTime.Now.AddDays(Convert.ToDouble((6 - Convert.ToInt16(DateTime.Now.DayOfWeek)))).ToShortDateString();


           lblMouthStart.Content = DateTime.Today.AddDays(-(DateTime.Today.Day) + 1).ToString("yyyy-MM-dd");
           lblMouthEnd.Content = DateTime.Today.AddMonths(1).AddDays(-(DateTime.Today.Day)).ToString("yyyy-MM-dd");//最后一天


            lblQuarterStart.Content = DateTime.Today.AddMonths(0 - (DateTime.Today.Month - 1) % 3).AddDays(1 - DateTime.Today.Day).ToString("yyyy-MM-dd"); 

            lblQuarterEnd.Content = DateTime.Today.AddMonths(0 - (DateTime.Today.Month - 1) % 3).AddDays(1 - DateTime.Today.Day).AddMonths(3).AddDays(-1).ToString("yyyy-MM-dd");   

            lblYearStart.Content = new DateTime(DateTime.Today.Year, 1, 1).ToString("yyyy-MM-dd");  

            lblYearEnd.Content = new DateTime(DateTime.Today.Year, 12, 31).ToString("yyyy-MM-dd"); 

 

说明:以lbl开头的为 Label 控件

WPF 本周、本月、本季、本年的第一天与最后一天取法,布布扣,bubuko.com

WPF 本周、本月、本季、本年的第一天与最后一天取法

标签:tar   c   int   string   art   a   

原文地址:http://www.cnblogs.com/kangjing/p/3718577.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!