Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

TimeToStr

  • Last UpdatedJul 18, 2023
  • 2 minute read

Converts a time/date variable into a string. Use this function for calculating time differences or run times, and so on. Set Format to 6 to convert time periods that are in milliseconds, such as the times that are returned from the SysTime() and SysTimeDelta() functions.

Note: Once a date/time is retrieved as UTC, the string cannot be used by the Cicode functions StrToDate and StrToTime to synthesize a date/time value as these functions support local time only.

Time/date functions can only be used with dates from 1980 to 2035. You should check that the date you are using is valid with Cicode similar to the following:

IF StrToDate(Arg1)>0 THEN

...

ELSE

...

END

Syntax

TimeToStr(Time, Format [, UTC] )

Time:

The time/date variable.

Format:

Format of the string:

0 - Short time format, hh:mm AM/PM.

1 - Long time format, hh:mm:ss AM/PM.

2 - Short date format, based on the system locale setting. For example, dd/mm/yy for English (Australia); mm/dd/yy for English (United States); or dd.mm.yy for German (Germany).

3 - Long date format, day month year.

4 - Time and date, weekday month day year hh:mm:ss AM/PM.

5 - Long time period, hh:mm:ss. Time needs to be in seconds.

6 - Millisecond time period, hh:mm:ss.xxx ("xxx" represents milliseconds). Time needs to be in milliseconds.

7 - Short time period, hh:mm. Time needs to be in seconds.

8 - Long time period, "xxxxx Days hh Hours mm min ss sec". Time needs to be in seconds.

9 - Extended date format, based on the system locale setting. For example, dd/mm/yyyy for English (Australia); mm/dd/yyyy for English (United States); or dd.mm.yyyy for German (Germany).

10 - Local TimeDate format, yyyy-mm-dd hh:mm:ss

11 - Time of Day, hh:mm:ss tt format with no date

UTC:

Coordinated Universal Time (optional)

0 - Display the string as a local date/time (default).

1 - Display the string as a UTC date/time (valid for formats 0-4 and 9).

Return Value

A string containing the converted time/date or period variable, or an empty string if invalid.

Time, TimeCurrent, Date

Example

! If the current system time is 11:50:00 a.m.

String=TimeToStr(TimeCurrent(),0);

! Sets String to "11:50 AM".

String=TimeToStr(125 + TimeCurrent(),5);

! Sets String to "11:52:05" (the current time + 2 minutes and 5
seconds).

See Also

Time and Date Functions

In This Topic
TitleResults for “How to create a CRG?”Also Available in