Platforms to show: All Mac Windows Linux Cross-Platform

DifferenceMBS(extends StartDate as date, EndDate as date) as DateDifferenceMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
global method Basic MBS Util Plugin 7.4 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Calculates the difference between two dates.
Example
dim d as date
dim e as date
dim r as DateDifferenceMBS
dim s as string

d=new date
d.Year=2008
d.Month=7
d.Day=2
d.Hour=10
d.Minute=48
d.Second=22

e=new date
e.Year=2010
e.Month=7
e.Day=1
e.Hour=10
e.Minute=36
e.Second=0

r=d.DifferenceMBS(e)

s= "Years: "+str(r.Year)+EndOfLine
s=s+"Months: "+str(r.month)+EndOfLine
s=s+"Days: "+str(r.day)+EndOfLine
s=s+"Hours: "+str(r.hour)+EndOfLine
s=s+"Minutes: "+str(r.Minute)+EndOfLine
s=s+"Seconds: "+str(r.Second)+EndOfLine

MsgBox s

// shows: "Years: 1 Months: 11 Days: 29 Hours: 22 Minutes: 47 Seconds: 38"

Returns nil on any errors. (one of the dates is nil or property getter don't work)
Valid only for dates from the gregorian calendar.

Calculates the difference between the older and newer date. The dates are sorted, so the difference is always a positive.
You can see Swap property to see if first date is after second date.

See also:

Some examples using this global method:

DifferenceMBS(extends StartDate as dateTime, EndDate as dateTime) as DateDifferenceMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
global method Basic MBS Util Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Calculates the difference between two dates.

Returns nil on any errors. (one of the dates is nil or property getter don't work)
Valid only for dates from the gregorian calendar.

Calculates the difference between the older and newer date. The dates are sorted, so the difference is always a positive.
You can see Swap property to see if first date is after second date.
Please make sure both dates are in the same timezone.

See also:

Some examples using this global method:

The items on this page are in the following plugins: MBS Util Plugin.


The biggest plugin in space...