Update cookies preferences
Promotic

DateDiff - method of the Pm object

Description:
Returns the number of time-spans between two dates.
Syntax:
Long DateDiff(String timeSpan, Date date1, Date date2)
Parameters:
timeSpan(String) Specifies type of time span used for calculation 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 first day is Sunday
"w1" - week, where first day is Monday
"w2" - week, where first day is Tuesday
"w3" - week, where first day is Wednesday
"w4" - week, where first day is Thursday
"w5" - week, where first day is Friday
"w6" - week, where first day is Saturday
date1(Date) First date for calculation
date2(Date) Second date for calculation
Note:
This method is functional also in Macro expression $.expr and in the onDraw event of the PmgCanvas object.
This method is also functional in 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 this case for example "H" returns the calendar difference of hours and "Hr" returns the real difference between those dates.
See Example.
See also:
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

History:
Pm8.03.26: Created
PROMOTIC 9.0.31 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
Navigation:
 
- Pm
 
- Abs
- Cos
- DateDiff
 
 
- E
- Exp
- LN2
- PI
- Pow
- Sin
- Tan
© MICROSYS, spol. s r.o.