DateTime.AddInterval
From Xojo Documentation
Method
DateTime.AddInterval(years As Integer, months As Integer, days As Integer, hours As Integer, minutes As Integer, seconds As Integer, nanoseconds As Integer) As DateTime
New in 2019r2
Supported for all project types and targets.
New in 2019r2
Supported for all project types and targets.
Adds the specified interval values to get a new DateTime.
Notes
You can also use the + and - operators to add DateIntervals to DateTime objects.
Sample Code
Get the date two months from today:
Var twoMonths As New DateInterval
twoMonths.Months = 2 // 2 month interval
// Get date two months from today
Var future As DateTime = DateTime.Now + twoMonths
// Get date two months before today
Var past As DateTime = DateTime.Now - twoMonths
// Next month
Var nextMonth As DateTime = DateTime.Now.AddInterval(0, 1)
twoMonths.Months = 2 // 2 month interval
// Get date two months from today
Var future As DateTime = DateTime.Now + twoMonths
// Get date two months before today
Var past As DateTime = DateTime.Now - twoMonths
// Next month
Var nextMonth As DateTime = DateTime.Now.AddInterval(0, 1)