|
|
|
|
|
- Validity of the dates
- Calculating the difference between two dates with the operators
DateTimeDifference (Function) In french: DateHeureDifférence Calculates the difference between two dates and times. Remarks: - You can also use the '-' (minus) operator to calculate the difference between two dates (see Remarks).
- To display the result of this function in a Duration variable, use StringToDuration.
Diff is string
Diff = DateTimeDifference("199801011215", SysDateTime())
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")
Diff is string = DateTimeDifference("199801011215", SysDateTime())
Durée1 is Duration = StringToDuration(Diff, durationCenti)
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 operation: <End Date/Time> - <Start Date/Time>. This result contains the '-' sign if the <Start date/time> is later than the <End date/time>. Warning To assign this result to a variable of type Duration, you need to use function StringToDuration with the constant durationHundredth. <Start date/time>: Character string or DateTime variable Start date/time in the following format:- YYYYMMDDHHmmSSCC
- YYYYMMDDHHmmSS
- YYYYMMDDHHmm
- YYYYMMDDHH
<End date/time>: Character string or DateTime variable End date/time in the following format:- YYYYMMDDHHmmSSCC
- YYYYMMDDHHmmSS
- YYYYMMDDHHmm
- YYYYMMDDHH
Remarks Validity of the dates 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. Calculating the difference between two dates with the operators The DateTimeDifference function can be replaced by the '-' operator. You can also assign the result directly to a variable of type Duration, which allows you to use a negative duration. Examples: duree_intervalle is Duration
IF date_heure_1 > date_heure_2 THEN
duree_intervalle = date_heure_1 - date_heure_2
ELSE
duree_intervalle = date_heure_2 - date_heure_1
END
duree_intervalle is Duration = date_heure_1 - date_heure_2
IF duree_intervalle < 0 THEN
duree_intervalle = - duree_intervalle
END
Business / UI classification: Neutral code
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|