ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Date and time functions
  • Format of result
  • Validity of the times
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Calculates the difference between two times in hundredths of a second.
Example
// Displays the time elapsed since 12:15
Diff is int
Time_Sign is string
MyResult is string
 
Diff = TimeDifference("1215", TimeSys())
MyResult = IntegerToTime(Abs(Diff))
IF Diff < 0 THEN Time_Sign = "-"
Info("Time elapsed: " + Time_Sign + Left(MyResult, 2) + " hours " + ...
Middle(MyResult, 3, 2) + " minutes " + ...
Middle(MyResult, 5, 2) + " seconds " + ...
Middle(MyResult, 7, 2) + " hundredths of a second")
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.
Reports and Queries

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: wd290std.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: 05/26/2022

Send a report | Local help