Promotic

FormatDate - method of the Pm object

Description:
Creates a text string containing date and time (according to the vFormat formatting rule).
This method is obsolete (but functional) and it is better to use the PmFormat object (see also PmFormat object formatting string).
Syntax:
String FormatDate(Date tDate, Variant vFormat)
Parameters:
tDate(Date) variable of the Date type (it holds the date and time)
vFormat(Variant) Type of the pre-defined conversion or formatting rule for the date and time conversion into the string. If the vFormat is of a numeric type, then the number is understood as the type of the pre-defined conversion.
1 - The internal way of date and time storing in the PROMOTIC system is in the form: 2022.10.23 15:23:28.082. This way ensures that the strings are sorted in compliance with the date and time sorting.
2 - Creates the time in the Internet format: Tue, 04 Jan 2022 15:23:28 GMT.
String type - If vFormat is of the String type, then it is the formatting rule for the time conversion into the string.
Example: "%d.%m.%Y_%H:%M:%S.%T", where:
d=day (01-31),
m=month (01-12),
Y=year (e.g. 2022),
H=hour (00-23),
M=minute (00-59),
S=second (00-59),
T=millisecond (000-999) - it is possible %nT, where n is count of figures 1, 2 or 3

Any of the chars %d, %m, %Y, %M, ... can be omitted and so to omit the corresponding time item in the presentation.
20 - Obsolete. Creates the time in the form suitable for the MS SQL database: '2022-10-23 15:23:28.082'.
It is better to use string type with value: '%Y-%m-%d %H:%M:%S.%T'.
21 - Obsolete. Creates the time in the form suitable for the Oracle database: TIMESTAMP'2022-10-23 15:23:28.082'.
It is better to use string type with value: TIMESTAMP'%Y-%m-%d %H:%M:%S.%T'.
22 - Obsolete. Creates the time in the form suitable for the MySQL database: '2022-10-23 15:23:28'.
It is better to use string type with value: '%Y-%m-%d %H:%M:%S'.
23 - Obsolete. Creates the time in the form suitable for the Microsoft Access, dBase, PARADOX databases when setting the direct access: #10 23 2022 15:23:28#.
It is better to use string type with value: #%m %d %Y %H:%M:%S#.
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. So far this is functional only for: vFormat = 1 and vFormat = String type.
Example1:
JavaScriptVBScriptSelect and copy to clipboard

var tDate = Pm.Time;
var sDate = Pm.FormatDate(tDate, "%d.%m.%Y_%H:%M:%S");
// sDate contains "24.07.2017_17:06:35"
Example2:
JavaScriptVBScriptSelect and copy to clipboard

var tDate = Pm.Time;
var sDate = Pm.FormatDate(tDate, "%d.%m.%Y_%H:%M:%S.%2T");
// sDate contains "24.07.2017_17:06:35.63"
PROMOTIC 9.0.21 SCADA system documentation - MICROSYS, spol. s r.o.

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