ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage syntax / WLanguage types
  • Overview
  • Addition
  • Subtraction
  • Comparison
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
Operations available for the dates, times and durations, ...
Overview
The following operations are available for the following types of variables: Date, Time, DateTime and Duration:
  • addition
  • subtraction
  • comparison
Remark: Several WLanguage functions can be used to handle the dates and times (see the functions for managing the dates and times).
Addition
The addition operations performed between the Date, Time, DateTime and Duration variables are presented in the table below. This table presents the type of result for each combination:
Added type
DateTimeDateTimeDuration
DateConcatenation of the elements into a stringConcatenation of the elements into a string. This string can be used by DateTimeDifferenceConcatenation of the elements into a stringDate variable (Time part ignored)
TimeConcatenation of the elements into a stringConcatenation of the elements into a stringConcatenation of the elements into a stringTime variable (Date part ignored)
DateTimeConcatenation of the elements into a stringConcatenation of the elements into a stringConcatenation of the elements into a stringDateTime variable
DurationDate variableTime variableDateTime variableDuration variable
// Add a DateTime variable and a Time variable
StartDateTime is DateTime = "200112051530"
EndDateTime is DateTime = "200112051730"
ConferenceDuration is Duration = EndDateTime - StartDateTime
 
AdditionalTime is Time = "0330"
FinalDateTime is DateTime
FinalDateTime = ConferenceDuration + AdditionalTime
// Add a DateTime variable and a Duration variable
dtMyDate is DateTime = DateSys() + TimeSys()
dtMyResultDate is DateTime

Trace("Start DateTime: " + dtMyDate)

StartTime is Time = "0117"
EndTime is Time = "2353"  
duMyDuration is Duration = EndTime - StartTime
Trace("Duration in hours: " + NumToString(duMyDuration.InHours) + "h")

dtMyResultDate = dtMaDate + duMyDuration
Trace("DateTime added to a duration: " + dtMyResultDate)
Subtraction
The subtraction operations performed between the Date, Time, DateTime and Duration variables are presented in the table below. This table presents the type of result for each combination:
Subtracted type
DateTimeDateTimeDuration
DateDuration variableErrorErrorDate variable
TimeErrorDuration variableErrorTime variable
DateTimeErrorErrorDuration variableDateTime variable
DurationErrorErrorErrorDuration variable
StartDateTime is DateTime = "200112051530"
EndDateTime is DateTime = "200112071730"
ConferenceDuration is Duration = EndDateTime - StartDateTime
Comparison
The comparison operators (=, <>, <, >, <=, >=) used between the Date, Time, DateTime and Duration variables are presented in the table below. For each combination this table shows if the comparison is possible.
Compared type
DateTimeDateTimeDuration
DatePossibleErrorPossible (Time part ignored)Error
TimeErrorPossiblePossible (Date part ignored)Error
DateTimePossible (Time part ignored)Possible (Date part ignored)PossibleError
DurationErrorErrorErrorPossible
StartDateTime is DateTime = "200112051530"
EndDateTime is DateTime = "200115051730"
IF EndDateTime > StartDateTime THEN
Info("The dates are valid")
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/06/2024

Send a report | Local help