ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Date and time functions
  • Format of result
  • Validity of the times
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Calculates the difference between two times in hundredths of a second.
Example
// Affiche le temps écoulé depuis 12h15
Diff is int 
Signe_temps is string
MonRésultat is string 

Diff = TimeDifference("1215", TimeSys())
MonRésultat = IntegerToTime(Abs(Diff))
IF Diff < 0 THEN Signe_temps = "-"
Info("Temps écoulé : " + Signe_temps + Left(MonRésultat, 2) + " heures " + ...
	Middle(MonRésultat, 3, 2) + " minutes " + ...
	Middle(MonRésultat, 5, 2) + " secondes " + ...
	Middle(MonRésultat, 7, 2) + " centièmes de seconde")
Syntax
<Result> = TimeDifference(<Start time> , <End time>)
<Result>: Integer
Number of hundredths of a second elapsed between the two times. This number is the result of the following operation:
<End time> - <Start time>.
The result is negative if <Start time> is after <End time>.
<Start time>: Character string or Time variable
Start time in the following format:
  • HHMMSSCC
  • HHMMSS
  • HHMM
  • HH
<End time>: Character string or Time variable
End time in the following format:
  • HHMMSSCC
  • HHMMSS
  • HHMM
  • HH
Remarks

Format of result

To get the duration in another format (HHMMSSCC for example), use IntegerToTime.
WINDEVJavaUser code (UMC)

Validity of the times

The validity of the times passed as parameters is checked. A message is displayed if the time is invalid. You can check the validity of a time using TimeValid.
Business / UI classification: Neutral code
Component: wd300std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Example
// Time passed since 01/01/1998 at 12:15
sTDatahoraAgenda is string = Middle(StringToDate(EDT_DataAgendamento)+StringToTime(Middle(EDT_DataAgendamento,12,5)),1,12) //"199801011215"
Diff is string
Diff = DateTimeDifference(sTDatahoraAgenda, DateSys() + TimeSys())
//Display the time passed
//Info("Time passed: " + CR + ...
//Left(Diff, 8) + "days" + CR + ...
//Middle(Diff, 9, 2) + "hours" + CR + ...
//Middle(Diff, 11, 2) + "minutes" + CR + ...
//Middle(Diff, 13, 2) + "seconds" + CR + ...
//Middle(Diff, 15, 2) + "hundredths of a second")

//Valida data
nSMinutos is int = Val(Middle(Diff, 11, 2))
IF CBOX_Agendamento..Value = True AND Middle(Diff, 11, 2) < 30
Info("A data e hora agendada tem que ser maior do que 30 minutos")
ok1 = False
ELSE
ok1 = True
END
adrianoboller
27 Nov. 2015

Last update: 03/27/2025

Send a report | Local help