Converts a duration to a character string in the specified format.
// Start time and end time
StartTime is Time = "125324"
EndTime is Time = "140852"
// Calculate the duration
MyDuration is Duration = EndTime - StartTime
// Format the duration in order to get a result in the same format as DateTimeDifference
Res = DurationToString(MyDuration, durationCenti) // Res = "001152800"
// Custom formatting
Res = DurationToString(MyDuration, "D-HH:MM") // Res = "0-01:15"
<Result> = DurationToString(<Duration> , <Format>)
<Result>: Character string
Character string in the specified format.
<Duration>: Duration variable
- Duration variable containing the duration in "+DHHMMSSCCC" format (D corresponds to the number of days, HH to hours, MM to minutes, SS to seconds and CCC to milliseconds).
- Duration in a readable format (e.g., 1 d 2 h 3 min 10 s 10 ms).
<Format>: Character string or constant
Format to apply to the duration. This parameter can correspond to:
- a character string (a sentence for example). The characters that represent the different elements of the duration (D, HH, MM, SS or CCC) will be automatically replaced with the value in the <Duration> parameter. The following characters are used in this string:
- + is used to take the negative numbers into account,
- D represents the number of days,
- HH represents the number of hours,
- MM represents the number of minutes,
- SS represents the number of seconds,
- CCC represents the number of milliseconds.
- one of the following constants:
|durationCenti||Format used: "+DHHMMSSCC". This format allows you to retrieve the result in the format used by DateTimeDifference.|
|durationMilli||Format used: "+DHHMMSSCCC"|
The direct assignment <String> = <Duration> is equivalent to using DurationToString with the "+DHHMMSSCCC" format.
Business / UI classification: Neutral code