Promotic

GetDateOf - method of the Pm object

Description:
Returns dates from defined base date.
Syntax:
Date GetDateOf(Long nOper, [Date tDate], [Long nPar1], [Long nPar2])
Parameters:
nOper(Long) Operation over the entered time:
 
1 - Conversion of the tDate input time type into the standard time, daylight-saving time or JavaScript time. See Example1.
The nPar1 parameter specifies the type of the input time (tDate) and the nPar2 parameter specifies the type of the output time.
0 = An current time. Automatic selection of the time type according to the current time period.
If is a daylight-saving time period, then the "daylight-saving time" will be selected.
If is a standard time period, then the "standard time" will be selected.
1 = standard time (is not functional for the Web).
2 = daylight-saving time (is not functional for the Web).
4 = JavaScript time as number of milliseconds (see JavaScript-Date).
11 - Time of application launch. The tDate parameter is not entered.
Parameters nPar1 and nPar2 are not used.
21 - Beginning of daylight-saving time in the year of the entered time. See Example2.
Parameters nPar1 and nPar2 are not used.
22 - Beginning of standard time in the year of the entered time.
Parameters nPar1 and nPar2 are not used.
23 - Beginning of daylight-saving time after the entered time.
Parameters nPar1 and nPar2 are not used.
24 - Beginning of standard time after the entered time.
Parameters nPar1 and nPar2 are not used.
25 - Beginning of daylight-saving time before the entered time.
Parameters nPar1 and nPar2 are not used.
26 - Beginning of standard time before the entered time.
Parameters nPar1 and nPar2 are not used.
27 - The closest pass after the entered time.
Parameters nPar1 and nPar2 are not used.
28 - The closest pass before the entered time.
Parameters nPar1 and nPar2 are not used.
41 (61,81) - Beginning of the (past, next) year.
Parameters nPar1 and nPar2 are not used.
42 (62,82) - Beginning of the (past, next) quarter. This can also be solved by the operation 43 (63,83) - see Example4.
Parameters nPar1 and nPar2 are not used.
43 (63,83) - Beginning of the (past, next) month. See Example3 and Example4.
The nPar1 parameter specifies the size of time block (see The meaning of the nPar1 parameter for time block operations).
The nPar2 parameter is not used.
44 (64,84) - Beginning of the (past, next) week (Monday is the first day of the week).
Parameters nPar1 and nPar2 are not used.
45 (65,85) - Beginning of the (past, next) day.
Parameters nPar1 and nPar2 are not used.
46 (66,86) - Beginning of the (past, next) hour. See Example6 and Example7.
The nPar1 parameter specifies the size of time block (see The meaning of the nPar1 parameter for time block operations).
The nPar2 parameter is not used.
47 (67,87) - Beginning of the (past, next) minute.
The nPar1 parameter specifies the size of time block (see The meaning of the nPar1 parameter for time block operations).
The nPar2 parameter is not used.
48 (68,88) - Beginning of the (past, next) second.
The nPar1 parameter specifies the size of time block (see The meaning of the nPar1 parameter for time block operations).
The nPar2 parameter is not used.
101 (121,141) - The last day of the (past, next) year.
Parameters nPar1 and nPar2 are not used.
102 (122,142) - The last day of the (past, next) quarter.
Parameters nPar1 and nPar2 are not used.
103 (123,143) - The last day of the (past, next) month.
Parameters nPar1 and nPar2 are not used.
104 (124,144) - The last day of the (past, next) week (Sunday is the last day of the week).
Parameters nPar1 and nPar2 are not used.
105 (125,145) - The last hour of the (past, next) day.
Parameters nPar1 and nPar2 are not used.
106 (126,146) - The last minute of the (past, next) hour.
Parameters nPar1 and nPar2 are not used.
107 (127,147) - The last second of the (past, next) minute.
Parameters nPar1 and nPar2 are not used.
tDate[optional] (Date) Entered time.
If the parameter is omitted (or the entered value is 0), then the current time is used as preset.
nPar1[optional] (Long) The meaning depends on the operation (on the nOper parameter).
For operations that do not use this parameter, the parameter is omitted, or the 0 value is entered.
nPar2[optional] (Long) The meaning depends on the operation (on the nOper parameter).
For operations that do not use this parameter, the parameter is omitted, or the 0 value is entered.
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. Only operations 1, 41-88 currently are functional for the Web.

The meaning of the nPar1 parameter for time block operations:
For operations 43,63,83 (beginning of month), 46,66,86 (beginning of hour), 47,67,87 (beginning of minute) and 48,68,88 (beginning of second) the nPar1 parameter can be used to define block so the result will not be the beginning of a month (hour, minute, second), but a beginning of block nPar1 of months (hours, minutes, seconds).
- Example for month: If nPar1 = 3, then the result will be the beginning of the three-month block (i.e. a beginning of quarter) - see Example4.
- Example for hour: If nPar1 = 8, then the result will be the beginning of 8-hour block (i.e. beginning of a shift) - see Example7. For example the shift starts at 6am every day then it is necessary to subtract 6 hours from the entry time and then add the 6 hours to the result (6 hours means 6/24).
Example1:
Detects the current time as "standard time" (even if the active "daylight-saving time" can be now):
JavaScriptVBScriptSelect and copy to clipboard

var d = Pm.GetDateOf(1, 0, 0, 1);
Example2:
Detects the pass time to "daylight-saving time" in 2023 year:
JavaScriptVBScriptSelect and copy to clipboard

var d = Pm.GetDateOf(21, Pm.CreateDate(2023, 1, 1, 0, 0, 0, 0));
Example3:
Detects the beginning of the current month:
JavaScriptVBScriptSelect and copy to clipboard

var d = Pm.GetDateOf(43, 0);
Example4:
Detects the beginning of this quarter (i.e. a 3-month block).
See The meaning of the nPar1 parameter for time block operations.
JavaScriptVBScriptSelect and copy to clipboard

var d = Pm.GetDateOf(43, 0, 3);
Example5:
Time value without date:
JavaScriptSelect and copy to clipboard

var tTime = Pm.Time - Pm.GetDateOf(45, 0);
Example6:
Detects the beginning of this hour:
JavaScriptVBScriptSelect and copy to clipboard

var d = Pm.GetDateOf(46, 0);
Example7:
Detects the beginning of this shift. The shift is represented by a 8-hour block that begins at 6am. Therefore in the example 6 hours (i.e. the 6/24 value) are subtracted from the entry time and then added to the output time.
See The meaning of the nPar1 parameter for time block operations.
JavaScriptVBScriptSelect and copy to clipboard

var d = Pm.GetDateOf(46, Pm.Time - 6 / 24, 8) + 6 / 24;

History:
Pm9.00.16: The nPar1=4 parameter is now supported for the operation 1 that can be used to obtain JavaScript time (as the number of milliseconds).
Pm9.00.09: Fixed bug: The method did not work in the Web panel if the tDate parameter was 0.
Pm8.02.16: Available for Web panels.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

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