Promotic
WikipediaLinkedInYoutubeTwitterFacebook

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 or daylight-saving time. See Example1.

The nPar1 parameter specifies the type of the input time and the nPar2 parameter specifies the type of the output time.

0 = An automatic 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.
2 = daylight-saving time.
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 (winter) 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 (winter) 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 (winter) 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 Example5 and Example6.

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 patrameter is omitted, or the value 0 is entered.

nPar2[optional] (Long) The meaning depends on the operation (on the nOper parameter).

For operations that do not use this parameter, the patrameter is omitted, or the value 0 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 41 - 88 currently are functional for 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 mont (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 beginnig 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 Example6. 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 in the standard seasons (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 2020 year:
JavaScriptVBScriptSelect and copy to clipboard

var d = Pm.GetDateOf(21, Pm.CreateDate(2020, 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:
Detects the beginning of this hour:
JavaScriptVBScriptSelect and copy to clipboard

var d = Pm.GetDateOf(46, 0);
Example6:
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 value 6/24) 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.09: Fixed bug: The method did not work in the Web panel if the tDate parameter was 0.
Pm8.02.16: Minor bugfixes enabling for Web panels.
PROMOTIC 9.0.15 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.Tavičská 845/21 703 00 Ostrava-Vítkovice