Platforms to show: All Mac Windows Linux Cross-Platform

DateDifferenceMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Basic MBS Util Plugin 7.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
A class to calculate the difference between two dates.
Example
// calculate difference between now and a date in 2008.

dim d as date
dim r as DateDifferenceMBS
dim s as string
dim c as Clipboard

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

dim e as new date // today

r=new DateDifferenceMBS(d, 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

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.

This class allows you to know exactly how many months/years are between two dates. Something that TotalSeconds calculations will not give you!

This class has no sub classes.

Some useful global functions for this class:

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

Some examples using this class:

Blog Entries

Release notes

  • Version 24.1
    • Fixed a bug in DateDifferenceMBS class related to an overflow in January.
  • Version 20.3
  • Version 20.0
    • Fixed DateDifferenceMBS handling of DateTime with respect of TotalSeconds handling.
  • Version 19.5

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


DatagramMBS   -   DateTimePicker


💬 Ask a question or report a problem
The biggest plugin in space...