ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage properties / Time and date management properties
  • Managing times
  • Managing durations
  • Operators available for hours
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
The Hour property is used to:
  • Get the time from a variable of type Time or DateTime, or the number of hours from a variable of type Duration.
  • Change the time in a variable of type Time or DateTime, or the number of hours in a variable of type Duration.
  • Retrieve the time or the number of hours from a Date item (in "Date and Time" or "Duration" format) or from an Time item.
    WEBDEV - Browser codePHP Not available.
  • Modify the time or the number of hours in a Date item (in "Date and Time" or "Duration" format) or in an Time item.
    WEBDEV - Browser codePHP Not available.
Remark: The Hour property simplifies time and duration offset operations (adding an hour, etc.).
Reminder: Date items are used to handle:
  • simple dates: "Year - Month - Day" (YYYYMMDD format)
  • dates and times: "Year - Month - Day - Hours - Minutes - Seconds - Milliseconds" (YYYYMMDDHHmmSSCCC format)
  • durations: "Number of days - Number of hours - Number of minutes - Number of seconds - Number of milliseconds" (+DHHMMSSCCC format)
Example
// Exemple sur une variable
HeureDébut is Time = "1230"
// Ajouter 10 heures
HeureDébut.Hour += 10   // HeureDébut correspond à 22h30
HeureDébut.Hour += 10   // HeureDébut correspond à 08h30
// Modifier les heures
HeureDébut.Hour = 10
// Exemple sur une rubrique
Journée.HeureDébut = "1230"
// Ajouter 10 heures
Journée.HeureDébut.Heure += 10	// HeureDébut correspond à 22h30
Journée.HeureDébut.Heure += 10	// HeureDébut correspond à 08h30
// Modifier les heures
Journée.HeureDébut.Heure = 10
Syntax

Finding out the hour of a Time, DateTime or Duration variable Hide the details

<Result> = <Time used>.Hour
<Result>: Integer
Time on 2 digits.
<Time used>: Time, DateTime or Duration
Name of the variable of type Time, DateTime or Duration to be used.

Modifying the time of a Time, DateTime or Duration variable Hide the details

<Time used>.Hour = <New time>
<Time used>: Time, DateTime or Duration
Name of the variable of type Time, DateTime or Duration to be used.
<New time>: Character string or integer
New time in digits, included between 0 and 23. Replaces the time in the specified variable.
WEBDEV - Browser codePHP Not available in browser code and in PHP

Finding out the time of a Time or Date item ("Date Time" or "Duration" format) Hide the details

<Result> = <Data file>.<Item>.Hour
<Result>: Integer
Time on 2 digits.
<Data file>: Character string
Name of the data file used. This name was defined in the data model editor or with the File Description type.
<Item>: Character string
Name of the item used. This name is defined in the data model editor or with the Item Description type.
WEBDEV - Browser codePHP Not available in browser code and in PHP

Modifying the time of a Time or Date item ("Date and Time" or "Duration" format) Hide the details

<Fichier de données>.<Rubrique>.Hour = <Nouvelle heure>
<Data file>: Character string
Name of the data file used. This name was defined in the data model editor or with the File Description type.
<Item>: Character string
Name of the item used. This name was defined in the data model editor or with the Item Description type.
<New time>: Character string or integer
New time in digits, included between 0 and 23. Replaces the time in the specified item.
Remarks

Managing times

Case 1: Direct assignment
When assigning directly (for example, Day.TimeStart.Time = n), the time must be between 0 and 23. A WLanguage error occurs if the specified time is invalid.
The notation Day.HourStart.Hour = Day.HourStart.Hour + 5 may generate a runtime error.
Case 2: Operations on hours
When performing operations on the times of the Time or Date items ("Date and Time" format), the change of time is automatically managed.
The addition or subtraction of hours automatically takes into account the change from hour 23 to hour 0.
Therefore, if an hour is added to:
  • a Time item corresponding to 23:35, the result will correspond to 0:35
  • a Date item ('Date and Time' format), the time and the date will be modified (a day will be added).
// Exemple sur une variable
HeureDébut is Time = "2335"
HeureDébut.Hour++                            // HeureDébut = 0035
DateDébut is Date = "202011262335"        // 26/11/2020 à 23:35
DateDébut.Heure++                             // 27/11/2020 à 00:35

Managing durations

If the number of hours in a duration is greater than 23:59, the number of days is automatically incremented.

Operators available for hours

The following arithmetic operators can be used with the Hour property:
  • ++ and --
  • += and -=
// Exemple sur une rubrique
Journée.HeureDébut = "1230"
Journée.HeureDébut.Heure++     // Ajouter 1 heure
Journée.HeureDébut.Heure+=5    // Ajouter 5 heures
Journée.HeureDébut.Heure-=5    // Retrancher 5 heures
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/13/2025

Send a report | Local help