DateDiff - method of object Pm

Returns the number of intervals between two dates.
DateDiff(interval As String, date1 As Date, date2 As Date) As Long
n = Pm.DateDiff(interval, date1, date2)
interval(String) Specifies the interval (type of time range) used to calculate the difference between date1 and date2
"Y" - year
"q" - quarter
"m" - month
"d" - day
"H" - calendar hour
"Hr" - real hour
"M" - calendar minute
"Mr" - real minute
"S" - calendar second
"Sr" - real second
"w0" - week, where the first day is Sunday
"w1" - week, where the first day is Monday
"w2" - week, where the first day is Tuesday
"w3" - week, where the first day is Wednesday
"w4" - week, where the first day is Thursday
"w5" - week, where the first day is Friday
"w6" - week, where the first day is Saturday
date1(Date) First date in the calculation
date2(Date) Second date in the calculation
The method can also be called in the graphic item events for Web panels.
If is date1 > date2, then the function returns a negative number.
When comparing December 31 to January 1 of the immediately succeeding year, function for year ("Y") returns 1 even if only a second has elapsed.
Difference between H, M, S and Hr, Mr, Sr:

If between date1 and date2 there is no transition standard time <-> daylight-saving time then there is no difference in those intervals.

If there is the transition then those intervals differ. In such case for example "H" returns the calendar difference of hours and "Hr" returns the real difference between those dates.

See Example.

JavaScriptVBScriptSelect and copy to clipboard

var nVal;
var tDate = Pm.CreateDate(2018, 3, 25, 0, 0, 0, 0);

nVal = Pm.DateDiff("d", tDate, Pm.Time);  //Returns the number of days between a date tDate and today

//The following example presumes that on the 2018.3.25 there is transition from standard time to daylight-saving time
var tDate2 = Pm.CreateDate(2018, 3, 25, 5, 0, 0, 0);
nVal = Pm.DateDiff("H", tDate, tDate2);  //Returns 5
nVal = Pm.DateDiff("Hr", tDate, tDate2);  //Returns 4
PROMOTIC 9.0.0 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
- Pm
- Abs
- Cos
- DateDiff
- E
- Exp
- LN2
- PI
- Pow
- Sin
- Tan
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice