Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

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 Console & Web iOS
global method Basic MBS Util Plugin 7.4 Yes Yes Yes Yes No
Function: 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"
Notes:
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.

Some examples using this method:

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins