Xojo.Core.Date.Subtract

From Xojo Documentation

Method

Xojo.Core.Date.Operator_Subtract(interval As Xojo.Core.DateInterval) As Xojo.Core.Date

Supported for all project types and targets.

You can subtract a Date and a DateInterval to get a new Date.


Method

Xojo.Core.Date.Operator_Subtract(dateValue As Xojo.Core.Date) As Xojo.Core.DateInterval

Supported for all project types and targets.

You can subtract a Date from a Date and get a DateInterval.

Sample Code

Get the date two months before today:

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

// Get date two months before today
Var past As Xojo.Core.Date = Xojo.Core.Date.Now - twoMonths

Calculate the interval until January 1, 2030:

Var d2 As New Xojo.Core.Date(2030, 1, 1, Xojo.Core.TimeZone.Current)
Var interval As Xojo.Core.DateInterval
interval = d2 - Xojo.Core.Date.Now