WINDEV WEBDEV WINDEV Mobile Others DateTimeDifference (Function) In french: DateHeureDifférence Calculates the difference between two dates and times.Note: To display the result of this function in a Duration variable, use StringToDuration.Example // Time passed since 01/01/1998 at 12:15Diff is stringDiff = DateTimeDifference("199801011215", DateSys() + TimeSys())// Display the time passedInfo("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") // Time passed since 01/01/1998 at 12:15Diff is stringDiff = DateTimeDifference("199801011215", SysDateTime())// Display the time passedInfo("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") // To fill a duration from the result of DateTimeDifferenceDiff is string = DateTimeDifference("199801011215", DateSys() + TimeSys())// convert the difference into a duration variableDuration1 is Duration = StringToDuration(Diff, durationCenti) // --------------------------------------------// Other possible solution // DateTime1 is DateTime = "199801011215"// DateTime2 is DateTime = SysDate() + SysTime()// Duration1 is Duration = DateTime2 - DateTime1// ---------------------------------------------- // Display the time passedInfo("Time passed: " + Duration1..Day + "days" + CR + ... Duration1..Hour + "hours" + CR + ... Duration1..Minute + "minutes" + CR + ... Duration1..Second + "seconds" + CR + ... Duration1..Millisecond + "thousandths of a second") // To fill a duration from the result of DateTimeDifferenceDiff is string = DateTimeDifference("199801011215", SysDateTime())// convert the difference into a duration variableDuration1 is Duration = StringToDuration(Diff, durationCenti) // --------------------------------------------// Other possible solution // DateTime1 is DateTime = "199801011215"// DateTime2 is DateTime = DateTimeSys()// Duration1 is Duration = DateTime2 - DateTime1// ---------------------------------------------- // Display the time passedInfo("Time passed: " + Duration1..Day + "days" + CR + ... Duration1..Hour + "hours" + CR + ... Duration1..Minute + "minutes" + CR + ... Duration1..Second + "seconds" + CR + ... Duration1..Millisecond + "thousandths of a second") Syntax = DateTimeDifference( , ) : Character stringNumbers of days, hours, minutes, seconds passed between two dates in +/-DDDDDDHHMMSSCC format where:DDDDDD is the number of days passed 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: - . The result is negative if is after .Caution: To assign this result to a Duration variable, you must use StringToDuration associated with the durationCenti constant. : Character string or DateTime variableStart date/time in the following format:YYYYMMDDHHMMSSCCYYYYMMDDHHMMSSYYYYMMDDHHMMYYYYMMDDHH : Character string or DateTime variableEnd date/time in the following format:YYYYMMDDHHMMSSCCYYYYMMDDHHMMSSYYYYMMDDHHMMYYYYMMDDHH Remarks The validity of dates and times passed in parameter is checked. A message is displayed if the date or time is invalid. A "Date - Time" is considered as being invalid if:The date is invalid. The date validity can be checked by DateValid.The time is invalid. The time validity can be checked by TimeValid.This function cannot be used to calculate the number of days between dates before October 14 1582 (the switch from the Julian calendar to the Gregorian calendar will not be taken into account). The 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.Component : wd250std.dll Minimum version required Version 9 This page is also available for…