vb.netで誕生日の年を現在の年に変更するには?
たとえば、私の誕生日は 1990 年 2 月 14 日です --> 2013 年 2 月 14 日
しかし、変更する日は、2/20 の日付に変更するように 2/14 ではないため、現在の日付には等しくありません。
誕生日の年を現在の年に変更するにはどうすればよいですか?
vb.netで誕生日の年を現在の年に変更するには?
たとえば、私の誕生日は 1990 年 2 月 14 日です --> 2013 年 2 月 14 日
しかし、変更する日は、2/20 の日付に変更するように 2/14 ではないため、現在の日付には等しくありません。
誕生日の年を現在の年に変更するにはどうすればよいですか?
AddYears
Dateオブジェクトのメソッドを使用してこのようなことを試してください
Dim myBirthday As Date = Date.Parse("2/14/1990")
myBirthday = myBirthday.AddYears(23)
私のドス・センタボス
'what about leap years
Dim myBirthday As DateTime = #2/29/2000#
'the following doesn't work
' Dim myBirthdayThisYear As DateTime = New DateTime(DateTime.Now.Year, myBirthday.Month, myBirthday.Day)
'this works
Dim myBirthdayThisYear As DateTime = DateSerial(DateTime.Now.Year, myBirthday.Month, myBirthday.Day)