Format()

Format

Format(Time ,FormatString [,TimeZone])

Returns

Formats the supplied time argument in the specified format.

Inputs

Time: The time argument to be formatted.
Behaviour: Required
Dimension: Collection, SingleValue, MultiCollection
Valid data types: DateTime, Decimal, Integer, String

FormatString: The string specifying how to format the time. 
Behaviour: Required
Dimension: Collection, SingleValue
Valid data types: String

TimeZone: The geographical or UTC offset time zone (e.g. "Australia/Perth" or "UTC+08:00"). If not supplied, it assumes the configured calendar time zone.
Behaviour: Optional
Dimensions: SingleValue
Valid data types: String

How to format data types

Format Codes

The following codes within the FormatString are replaced with the relevant information. The codes are not case sensitive.

  • The codes must be in quotation marks. E.g. "Day"
  • You may concatenate the codes to produce the desired string. E.g. "DayMonth"
  • You may include other text, spaces, and punctuation within the quotation marks. E.g. "Day, Month"
  • Any other text within the quotation marks is converted to upper case.
DDD Day of year (001 to 366)
DAY Full weekday name
DY Abbreviated weekday name, e.g. FRI
MONTH Full month name
MON Abbreviated month name, e.g. AUG
HH12 Hour in 12 hour format (1 - 12)
HH Hour in 12 hour format (1 - 12)
HH24 Hour in 24 hour format (00 - 23)
YYYY Four-digit year
A.M. AM or PM indicator
AM AM or PM indicator
P.M. AM or PM indicator
PM AM or PM indicator
WW Week of year, if Sunday is the first day of the week
IW Week of year, if Monday is the first day of the week
DD Day of month (01 to 31)
MM Month (01 to 12)
MI Minutes (00 to 59)
SS Seconds (00 to 59)
D Day of week
IY Two-digit year (00 to 99)
YY Two-digit year (00 to 99)

 

Examples

Expression: Format(Time(), "MON")
Result: Format the date returned by the Time() expression, as the abbreviated month name.
E.g. Jul

Expression: Format(TimeOf({entity[Field]:Gas.Flowrate}), "DD-MON-YYYY")
Result: Format the date returned by the TimeOf() expression, as the day of month, abbreviated month name, and four-digit year.
E.g. 13-Jul-2016

Expression: Format({tagname}, "DD HH24:MI")
Result: Format the time of the supplied tag as a day and time.
E.g. 13 13:42

Expression: Format(CalendarDayStart(January(Time())), "HH24:MI:SS DD-MON-YYYY")
Result: Format the time returned by the CalendarDayStart() expression, as a timestamp with the time followed by the date.
E.g. 00:00:00 01-Jan-2016

Expression: Format(Time(), "DAY DD MONTH, YYYY HH24:MI:SS")
Result: Format the time returned by the Time() expression, as a timestamp with the date followed by the time.
E.g. Wednesday 13 July, 2016 13:42:21

Expression: Format(1232256720.0, "DD/MM/YY HH24:MI:SS")
Result: Format the supplied time (in seconds since epoch) as a timestamp with the date followed by the time.
E.g. 18/01/09 14:32:00

Expression: Format({utc'2017-06-15 00:00'}, "DAY HH24:MI", "Australia/Perth")
Result: Format the supplied time as a time in the specified time zone. Examples:
For time zone Australia/Perth: Thursday 08:00
For time zone Europe/Budapest: Thursday 02:00
For time zone America/DenverWednesday 18:00

Release History

  • Format() 4.6.5
    • Changed Time parameter to support MultiCollection values.
  • Format() 4.0
    • Initial version

Comments are closed