PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
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 dates and times.
Remarks:
  • It is also possible to use the '-' operator (minus) operator to calculate the difference between two dates.
  • To display the result of this function in a Duration variable, use StringToDuration.
Versions 17 and later
iPhone/iPad This function is now available for iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for iPhone/iPad applications.
iPhone/iPad This function is now available for iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android widget mode.
New in version 18
Android Widget This function is now available in Android widget mode.
Android Widget This function is now available in Android widget mode.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Versions 26 and later
Apple Watch This function is now available for Apple Watch applications.
New in version 26
Apple Watch This function is now available for Apple Watch applications.
Apple Watch This function is now available for Apple Watch applications.
Example
// Temps écoulé depuis le 01/01/1998 à 12h15
Diff is string
Diff = DateTimeDifference("199801011215", SysDateTime())
// Affichage temps écoulé
Info("Temps écoulé: " + CR + ...
Left(Diff, 8) + "jours" + CR + ...
Middle(Diff, 9, 2) + "heures" + CR + ...
Middle(Diff, 11, 2) + "minutes" + CR + ...
Middle(Diff, 13, 2) + "secondes" + CR + ...
Middle(Diff, 15, 2) + "centièmes de seconde")
// Pour remplir une durée à partir du résultat de DateHeureDifférence
Diff is string = DateTimeDifference("199801011215", SysDateTime())
// convertir la différence dans une variable de type durée
Durée1 is Duration = StringToDuration(Diff, durationCenti)
 
// --------------------------------------------
// Autre solution possible
// DateHeure1 est une DateHeure = "199801011215"
// DateHeure2 est une DateHeure = DateHeureSys()
// Durée1 est une durée = DateHeure2 - DateHeure1
// ----------------------------------------------
 
// Affichage temps écoulé
Info("Temps écoulé: " + Durée1.Day + "jours" + CR + ...
Durée1.Hour + "heures" + CR + ...
Durée1.Minute + "minutes" + CR + ...
Durée1.Second + "secondes" + CR + ...
Durée1.Millisecond + "millièmes de seconde")
Syntax
<Result> = DateTimeDifference(<Start date/time> , <End date/time>)
<Result>: Character string
Numbers of days, hours, minutes and seconds elapsed between two dates in +/-DDDDDDHHMMSSCC format where:
  • DDDDDD is the number of days elapsed between the two specified "Date - Time",
  • HH is the number of hours,
  • MM is the number of minutes,
  • SS is the number of seconds,
  • CC is the number of hundredths of a second.
This result comes from the following operation: <End date/time> - <Start date/time>.
The result is contains the sign '-' if the <Start Date/Time> is later than the <End Date/Time>.
Caution: To assign this result to a Duration variable, use StringToDuration with the durationCenti constant.
<Start date/time>: String or Variable of type DateTime
Start date/time in the following format:
  • YYYYMMDDHHmmSSCC
  • YYYYMMDDHHmmSS
  • YYYYMMDDHHmm
  • YYYYMMDDHH
<End date/time>: String or Variable of type DateTime
End date/time in the following format:
  • YYYYMMDDHHmmSSCC
  • YYYYMMDDHHmmSS
  • YYYYMMDDHHmm
  • YYYYMMDDHH
Remarks
The validity of the dates and times passed as parameters is checked. A message is displayed if the date or time is invalid. A "Date - Time" is considered invalid if:
  • The date is invalid. You can check the validity of a date using DateValid.
  • The time is invalid. You can check the validity of a time using TimeValid.
This function cannot be used to calculate the difference between two dates before October 14, 1582 (the change from the Julian to the Gregorian calendar will not be taken into account).
The date storage format allows you to store dates from 01/01/0001 to 12/31/9999.
The calculations performed on dates by the WLanguage functions or by the WLanguage properties are accurate from January 1st 1583.
Business / UI classification: Neutral code
Component: wd270std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment