|
- Values of a duration
- The properties that can be used on the durations
- Supported values
- Displaying a duration in an edit control
Duration (Type of variable) In french: Durée
The Duration type is used to easily handle the intervals of dates and times. The DateTime type can be used to perform calculations (subtraction, addition, ...). For more details, see Operations that can be performed on the Duration type. Remarks: - Several properties can be used with the Duration type, to retrieve the number of days or minutes for example.
- To assign a duration coming from the result of a function, use StringToDuration.
- For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Versions 20 and later New in version 20
StartTime is Time = "1330" EndTime is Time = "1730" ConferenceDuration is Duration = EndTime - StartTime
Versions 23 and later
TaskDuration is Duration = 3 Min 30s
New in version 23
TaskDuration is Duration = 3 Min 30s
TaskDuration is Duration = 3 Min 30s
Syntax
Declaring and initializing a variable Hide the details
<Variable name> is Duration = <Value> OR
<Variable name> is Duration <Variable name> = <Value>
<Variable name>: Name of the variable to declare. When several variables of the same type are declared and initialized on the same line, only the last variable is initialized. <Value>: In most cases, a duration is the result of an operation performed on Date, Time or DateTime variables. This value can correspond to: - a character string,
- an integer (duration in milliseconds),
- a duration (for example, another duration variable),
Versions 23 and laterthe duration in a readable format (e.g.,: 30 s). New in version 23the duration in a readable format (e.g.,: 30 s). the duration in a readable format (e.g.,: 30 s). 0 is used to re-initialize the duration. Remarks Values of a duration If a Duration variable is handled: - using a string, this string is in the following format: "+DHHMMSSCCC" (days, hours, minutes, seconds, thousandths of a second).
- using an integer, this integer corresponds to the duration in milliseconds.
- using a duration, this duration can correspond to a Duration variable or to a clear description of the duration.
In most cases, a duration is the result of an operation performed on Date, Time or DateTime variables. This value can be a duration. 0 is used to re-initialize the duration. The properties that can be used on the durations The following properties can be used on the durations: | | InHours | Returns or modifies the number of hours corresponding to a duration. The number of hours is expressed in real format. | InDays | Returns or modifies the number of days corresponding to a duration. The number of days is expressed in real format. | InMilliseconds | Returns or modifies the number of milliseconds corresponding to a duration. The number of milliseconds is expressed in integer format. | InMinutes | Returns or modifies the number of minutes corresponding to a duration. The number of minutes is expressed in real format. | InSeconds | Returns or modifies the number of seconds corresponding to a duration. The number of seconds is expressed in real format. | Time | Returns or modifies the number of hours. The number of hours is expressed in integer format. | Day | Returns or modifies the number of days. The number of days is expressed in integer format. | Millisecond | Returns or modifies the number of milliseconds. The number of milliseconds is expressed in integer format. | Minute | Returns or modifies the number of minutes. The number of minutes is expressed in integer format. | Second | Returns or modifies the number of seconds. The number of seconds is expressed in integer format. |
For more details on the possible operations on durations (add, subtract, compare), see Operations that can be performed on the Duration type.
StartTime is Time = "1330" EndTime is Time = "1730" ConferenceDuration is Duration = EndTime - StartTime Info("The conference lasted: " + ConferenceDuration.Hour + " hours")
Important: To store the values of the properties listed in the above table, you must respect the type of variable returned by each property. For example:
MyDuration is Duration HowManyHours is real MyDuration.Day = 5 HowManyHours = MyDuration.InHours Info(MyDuration.Day + " days = " + HowManyHours + " hours")
In this example, the HowManyHours variable must be declared as real (and not as integer). If this variable is declared as integer, its value will be approximative. Supported values The Duration type is used to manage the durations included between plus and minus 2 billion days. The precision is up to the millisecond. Displaying a duration in an edit control
Related Examples:
|
Unit examples (WINDEV): Calculations on durations
[ + ] Calculations on dates and times with the WLanguage functions: - Calculate the duration between two moments (dates and times) - Calculate a sum of durations - Calculate an average of durations
|
This page is also available for…
|
|
|
| |
| | Global gduTempoMaximo is Duration = 5min
--- Thread in Procedure Infinito e inicio automaico em um segundo ---
gduTempoMaximo..Second -= 1
STC_TempoRestante = NumToString(gduTempoMaximo..Hour,"02d") + ":" + NumToString(gduTempoMaximo..Minute,"02d") + ":" + NumToString(gduTempoMaximo..Second,"02d")
---- Tempo Restante: 00:04:55
|
|
|
|
| |
| |
| |
|
| Displaying a duration in Table column |
|
| DateTimeLOGIN = Table.MyLOGIN DateTimeLOGOUT = Table.MyLOGOUT MyDuration = DateTimeDifference(DateTimeLOGIN,DateTimeLOGOUT)+"0" Table.MyDuration = MyDuration
Adding the "0" to the result of the calculation is necessary to get a correct display!
|
|
|
|
| |
| |
| |
|
| Duration..Hour help page documentation error |
|
| The Hour property of the Duration has been incorrectly labelled as "...Time". It should read "..Hour" |
|
|
|
| |
| |
| |
| |
| |
| |
| | |
| |