Converts a duration in character string format to a duration that can be used by a
Duration variable.
Remark: This function is mainly used to assign the result of
DateTimeDifference to a Duration variable.
// To fill a duration from the result of DateTimeDifference
sDiff is string
sDiff = DateTimeDifference(sStart, sEnd)
// Convert the difference to a Duration variable
dDuration is Duration
dDuration = StringToDuration(sDiff, durationCenti)
sMyString is string = "The duration is 3 days, 13 hours, 45 minutes."
dDuration is Duration
dDuration = StringToDuration(sMyString, "The duration is D days, HH hours, MM minutes.")
Trace(dDuration)
Syntax
<Result> = StringToDuration(<String> , <Format>)
<Result>: Duration variable
Duration in a format recognized by the Duration variables.
<String>: Character string
Duration in the format specified in <Format>.
<Format>: Character string
Format of the duration to convert. This format corresponds 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 <String> parameter. In this string:
- 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": used to create a duration from the format of the result of DateTimeDifference |
durationMilli | Format used: "+DHHMMSSCCC" |
Remarks
The direct assignment <Duration variable> = <String> is equivalent to using StringToDuration with the "+DHHMMSSCCC" format.
Business / UI classification: Neutral code