Say the user specifies these two dates....
Start 开发者_开发技巧Date: 2010-12-05 End Date: 2011-01-15If I select December 2010 I should get the folllowing
startdate = 2010-12-05 enddate = 2010-12-31Select January 2011 then
startdate = 2011-01-01 enddate = 2011-01-15Should I subtract dates? How can I get the start and enddate
for the current month/year based on the overall start and end date. I'm coding in vb.netIf my telepathy still works, it could be something like:
Dim startDate As Date = DateTimePicker1.Value
Dim endDate As Date = DateTimePicker2.Value
Dim selectedDate As Date = New DateTime(DateTimePicker3.Value.Year, DateTimePicker3.Value.Month, 1)
If selectedDate >= startDate AndAlso selectedDate <= endDate Then
Dim resultStartDate = New DateTime(Math.Max(startDate.Ticks, selectedDate.Ticks))
Dim resultEndDate = New DateTime(Math.Min(endDate.Ticks, selectedDate.AddMonths(1).AddDays(-1).Ticks))
Else
MsgBox("Outside of range")
End If
精彩评论