如何在vb.net中只比较日期部分和月份
问题描述:
我的要求是我必须计算某个日期和两个月之间的发生 假设我有10-jan-2012现在我有一个日期范围1- 2012年1月1日至2013年1月1日之间我的要求是,如果我发现1-jan-2012之间1-feb-2013之间的10-jan,无论年份如何,我都知道10-jan会在1 -an- 1 - 2月 - 2013我不理解怎么干这事meanto说,我要比较的日期只有一天,一个月的部分,这将解决我的问题如何在vb.net中只比较日期部分和月份
任何帮助会为我
答
是巨大的暗示
下面是我该怎么做(如果我正确地理解了这个问题):
Private Function GetCount(ByVal firstDate As DateTime, ByVal lastDate As DateTime, ByVal toFind As DateTime) As Integer
Dim count = 0
For i As Integer = firstDate.Year To lastDate.Year
Dim current = New Date(i, toFind.Month, toFind.Day)
If firstDate < current AndAlso current < lastDate Then
count += 1
End If
Next
Return count
End Function