如何获得一个月的第一个和最后一个日期 [英] How to get the First and Last date of a month
问题描述
大家好,
我想查找一个月的第一个和最后一个日期.谁能帮我解决这个问题.我有一个充满月份的组合框,即一月,二月,三月...等.现在我想要的是我将从组合框中选择月份",那么我应该获得该月的第一个和最后一个日期.有人可以帮我吗?
预先感谢
Jagdish
Hello everyone,
I want to find the first and last date of a month. can anyone help me out how to get it. I have a combobox filled with months i.e. January, February,March,...... and so on. Now what i want is i will select the Month from the combobox, then i should get the first and last date of that month. Can any one help me out in doing so.
Thanks in Advance
Jagdish
推荐答案
我发现这 [ ^ ]在 ^ ]. 在搜索引擎之前总是点击搜索引擎,因为它经常出现在&很简单,您可以通过在CP中进行搜索来找到它.
I found this[^] in 1st page of Google[^]. Always hit in search engine before asking here because it''s frequent & easy one, You can find this by searching in CP.
很显然,该月的第一天是 1 大>:rolleyes:
可以从 Calendar.GetDaysInMonth [
Well quite obviously the first day of the month is 1 :rolleyes:
The last day can be obtained from Calendar.GetDaysInMonth[^]
Private Function GetFirstDateOfMonth(ByVal iMonth As Integer)<br />
Dim dtFrom As DateTime = New DateTime(DateTime.Now.Year, iMonth, 1)<br />
dtFrom = dtFrom.AddDays(-(dtFrom.Day - 1))<br />
Return dtFrom<br />
End Function<br />
<br />
Private Function GetLastDateOfMonth(ByVal iMonth As Integer)<br />
Dim dtTo As New DateTime(DateTime.Now.Year, iMonth, 1)<br />
dtTo = dtTo.AddMonths(1)<br />
dtTo = dtTo.AddDays(-(dtTo.Day))<br />
Return dtTo<br />
End Function
我找到了查询的答案,因此想到了将其发布在这里.我们可以从这些函数中获取一个月的第一个和最后一个日期.
I found the answer for my query so thought of posting it here. we can get the first and last date of a month from these functions.
这篇关于如何获得一个月的第一个和最后一个日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!