2012-01-12 89 views
-1

我的要求是我必須計算某個日期和兩個月之間的發生 假設我有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中只比較日期部分和月份

任何幫助會爲我

回答

3
是巨大的暗示

下面是我該怎麼做(如果我正確地理解了這個問題):

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 
相關問題