当月获得第一天和最后一天 [英] Getting first and last day of the current month

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

问题描述

我这里有2日期选择为开始日期结束日期



我怎么能拿到第一一天,当月的最后一天

  rdpStartDate.SelectedDate = DateTime.Now; 
rdpEndDate.SelectedDate = DateTime.Now;


解决方案

 的DateTime现在= DateTime.Now; 
变种的startDate =新日期时间(now.Year,now.Month,1);
变种结束日期= startDate.AddMonths(1).AddDays(-1);


I have here 2 datepicker for start date and end date.

how can I get the first day and last day of the current month

rdpStartDate.SelectedDate = DateTime.Now;
rdpEndDate.SelectedDate = DateTime.Now;

解决方案

DateTime now = DateTime.Now;
var startDate = new DateTime(now.Year, now.Month, 1);
var endDate = startDate.AddMonths(1).AddDays(-1);

这篇关于当月获得第一天和最后一天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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