本文介绍了如何找到START DATE&所选月份的结束日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Friends,

        I have month & Year ( "March" & "2013" ) how can i find first date and last date of this month and Year. ( Like start date - 03/01/2013  & End date - 03/31/2013 )

推荐答案

DateTime firstDay = new DateTime(2013, 3, 1);
DateTime lastDay = firstDay.AddMonths(1).AddDays(-1);



但是有一对夫妇:)



如果你想使用一个字符串


but there''s quite a couple :)

if you like to use a string

var firstDay = DateTime.Parse("1 March 2013");
var lastDay  = firstDay.AddMonths(1).AddDays(-1);


DateTime start = new DateTime(2013,3,1);
DateTime end = new DateTime(2013,3,DateTime.DaysInMonth(2013,3));





祝你好运

Espen Harlinn



Best regards
Espen Harlinn


DateTime firstDateOfMonth = new DateTime(year, month, 1);
DateTime lastDateOfMonth = new DateTime(year, month, DateTime.DaysInMonth(year, month));


这篇关于如何找到START DATE&所选月份的结束日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 09:25