DateInterval

From Xojo Documentation

Class (inherits from Object)


New in 2019r2

A DateInterval is used to modify a date object. You specify how much you want to offset the date by and then add (or subtract) the interval to the date to get a new date object.

Properties
Days Months Years
Hours NanoSeconds
Minutes Seconds
Constructors

Constructor(years As Integer = 0, months As Integer = 0, days As Integer = 0, hours As Integer = 0, minutes As Integer = 0, seconds As Integer = 0, nanoseconds As Integer = 0)


Examples

This example adds 5 days to the current date:

Var d As DateTime = DateTime.Now
Var interval As New DateInterval(0, 0, 5)
d = d + interval
MessageBox(d.ToString)

This example adds 1 year, 3 months and 4 days to the current date:

Var d As DateTime = DateTime.Now
Var interval As New DateInterval(1, 3, 4)
d = d + interval
MessageBox(d.ToString)

This example adds 8 hours to the current date:

Var d As DateTime = DateTime.Now
Var interval As New DateInterval(0, 0, 0, 8)
d = d + interval
MessageBox(d.ToString)

See Also

DateTime class