PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Values of a duration
  • The properties that can be used on the durations
  • Supported values
  • Displaying a duration in an edit control
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
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, ...). See Operations that can be performed on the Duration type for more details.
Notes:
  • 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.
  • See Declaring a variable for more details.
Versions 20 and later
WEBDEV - Browser code This type of variable is now available in browser code.
New in version 20
WEBDEV - Browser code This type of variable is now available in browser code.
WEBDEV - Browser code This type of variable is now available in browser code.
Example
StartTime is Time = "1330"
EndTime is Time = "1730"    
ConferenceDuration is Duration = EndTime - StartTime
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 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 be a duration.
0 is used to re-initialize the duration.
Remarks

Values of a duration

If a duration variable is handled by a string, this string has the following format: "+DHHMMSSLLL" (days, hours, minutes, seconds, thousandths of a second).
If a duration variable is handled by an integer, this integer corresponds to the number of milliseconds for 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:
InHoursReturns or modifies the number of hours corresponding to a duration. The number of hours is expressed in real format.
InDaysReturns or modifies the number of days corresponding to a duration. The number of days is expressed in real format.
InMillisecondsReturns or modifies the number of milliseconds corresponding to a duration. The number of milliseconds is expressed in integer format.
InMinutesReturns or modifies the number of minutes corresponding to a duration. The number of minutes is expressed in real format.
InSecondsReturns or modifies the number of seconds corresponding to a duration. The number of seconds is expressed in real format.
TimeReturns or modifies the number of hours. The number of hours is expressed in integer format.
DayReturns or modifies the number of days. The number of days is expressed in integer format.
MillisecondReturns or modifies the number of milliseconds. The number of milliseconds is expressed in integer format.
MinuteReturns or modifies the number of minutes. The number of minutes is expressed in integer format.
SecondReturns or modifies the number of seconds. The number of seconds is expressed in integer format.
See Operations that can be performed on the Duration type for more details.
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

To display a duration in an edit control, you have the ability to use ..DisplayMask. See Display mask for durations for more details.
Related Examples:
Calculations on durations 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
Minimum version required
  • Version 9
This page is also available for…
Comments
Contador Regressivo
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

BOLLER
10 Sep. 2019
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!

Guenter
29 May 2018
Exemplo Data e hora
//Calculo Dias
_data_inicial is Date =SAI_data_inicial
_Data_final is Date = SAI_data_final
du_diferenca_data est une Durée // Em Frances
du_diferenca_data = _Data_final - _data_inicial
SAI_dias=du_diferenca_data..Day

//Calculo horas
h_hora_inicial is Time = SAI_Hora_Inicial
h_hora_final is Time = SAI_Hora_Final
du_diferenca_hora is Duration // Em Ingles
du_diferenca_hora=h_hora_final-h_hora_inicial
SAI_horas=du_diferenca_hora..Hour
SAI_minutos=du_diferenca_hora..Minute

//Blog com Video e Exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/01/curso-windev-datas-001-diferenca-entre.html
De matos AMARILDO
28 Jan. 2016
Duration..Hour help page documentation error
The Hour property of the Duration has been incorrectly labelled as "...Time". It should read "..Hour"
John
09 Dec. 2014