私は2つの日付を持っているとしましょう:
Date.Now :#8/10/2013 10:53:46 PM#
2 番目の日付はファイルの作成日です。
#7/10/2011 9:57:58 PM#
私は次のようなことをしたい: Date.Now - FileDate
.
これは私のコードです:
Dim ddd As TimeSpan = Date.Now - SecondDate
タイムスパンに「年」プロパティはありません。(年プロパティはあるべき2
2013 - 2011 = 2
ですが、日のプロパティがあります - しかし、年と月を取得する必要があります)
アップデート:
みんなありがとう、でも私は関数を作成しました:
Public Class Timee
Private _Days As Integer
Public Property Days() As Integer
Get
Return _Days
End Get
Set(ByVal value As Integer)
_Days = value
End Set
End Property
Private _Months As Integer
Public Property Months() As Integer
Get
Return _Months
End Get
Set(ByVal value As Integer)
_Months = value
End Set
End Property
Private _Years As Integer
Public Property Years() As Integer
Get
Return _Years
End Get
Set(ByVal value As Integer)
_Years = value
End Set
End Property
End Class
Public Function GetTimeBetween(ByVal datee As Date, ByVal datee2 As Date) As Timee
Dim tt As TimeSpan = datee - datee2
Dim dd11 As Integer = tt.Days
Dim bb1 As Integer
Dim Month As Integer
Dim Years1 As Integer
Do Until dd11 <= 0
bb1 = dd11
dd11 = dd11 - 365
Years1 = Years1 + 1
Loop
Years1 = Years1 - 1
Dim Dayss As Integer
Do Until bb1 <= 0
Dayss = bb1
bb1 = bb1 - 30
Month = Month + 1
Loop
Dim tt1 As New Timee
tt1.Days = Dayss
tt1.Months = Month
IF Years1 < 0 Then
Years1 = 0
End IF
tt1.Years = Years1
Return tt1
End Function
それが誰かを助けたことを願っています。