DateTime.SubtractInterval

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

DateTime.SubtractInterval(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.

Subtracts the specified interval values to get a new DateTime.

Notes

You can also use the - operator to subtract DateIntervals from DateTime objects.

Sample Code

Get the date two months ago:

Var twoMonths As New DateInterval
twoMonths.Months = 2 // 2 month interval

// Get date that was two months ago
Var past As DateTime = DateTime.Now - twoMonths

// Get date two months after today
Var future As DateTime = DateTime.Now + twoMonths

// last month
Var lastMonth As DateTime = DateTime.Now.SubtractInterval(0, 1)