Reputation: 55
I've seen varying discussions on here on converting between different date formats; what I'm curious on how to do in VB.Net is convert between integer and date and back again.
So for example, if 1 is 01/10/1990 and 9 is 09/10/1990; how would I convert back and forth on wider ranges in VB.Net?
My example dates are purely hypothetical, realistically it will be say 1 is 1/10/1984, whereas 1990 may have a 365.25 *6 increase.
Thanks for all your input thus far
Resolved
Upvotes: 0
Views: 106
Reputation: 1556
Try this....
Dim date1 As New Date(1990, 10, 01)
Dim newDate = date1.AddDays(1000)
Dim dateInterval = newDate.Subtract(date1).TotalDays
'newDate' is now 1000 days after 1990, 10, 01
and
'dateInterval' should = 1000 days
Hope that helps....
Upvotes: 2
Reputation: 65825
Does the integer that you are using matter? If not, just use Ticks:
// Convert current date/time to ticks
Dim n As Long = Now.Ticks
// Make ticks into new Date/time
Dim d As Date = New Date(n)
Upvotes: 0