将年和月转换为days.first转换回年和月,现在想转换回days.code就像下面的那个
if len >366
len1 = cstr (math.floor(len/365))
len = len mod 365
len1 = len * 365
提前致谢
答案 0 :(得分:1)
Dim July as integer = 7
' daysInJuly gets 31.
Dim daysInJuly as integer = System.DateTime.DaysInMonth(2001, July);
然后获得一年中的日子:
Private Function GetDaysInAYear(year As Integer) As Integer
Dim days As Integer = 0
Dim i As Integer = 1
While i <= 13
days += DateTime.DaysInMonth(year, i)
i++
End While
Return days
End Function
答案 1 :(得分:0)
要获得一年中的日子,您可以简单地执行此操作:
Dim year As Integer = 2012 ' Set year here
Dim totalDaysInYear As Integer = New Date(year, 12, 31).Subtract(New Date(year, 1, 1)).Days
或:(易于理解)
Dim year As Integer = 2012 ' Set year here
Dim d1 As New Date(year, 1, 1)
Dim d2 As New Date(year, 12, 31)
Dim totalDaysInYear As Integer = d2.Subtract(d1).Days
为了得到几个月的日子:
Dim year As Integer = 2012
Dim DaysInMonth As Integer = Date.DaysInMonth(year, 11) ' Evaluates Nov 2012
答案 2 :(得分:-2)
days = years * 365.25
years = days / 365.25