ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage properties / Time and date management properties
  • Managing times
  • Managing durations
  • Operators available for hours
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
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.
  • Modify the time or the number of hours in a Date item (in "Date and Time" or "Duration" format) or in an Time item.
Remark: The Hour property is used to easily change times and durations (add one hour, etc.).
Reminder: Date items are used to manage:
  • 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
// Example on a variable
StartTime is Time = "1230"
// Add 10 hours
StartTime.Hour += 10   // StartTime corresponds to 10:30 PM
StartTime.Hour += 10   // StartTime corresponds to 08:30 AM
// Modify hours
StartTime.Hour = 10
// Example on an item
Day.StartTime = "1230"
// Add 10 hours
Day.StartTime.Hour += 10 // StartTime corresponds to 10:30 PM
Day.StartTime.Hour += 10 // StartTime corresponds to 08:30 AM
// Modify hours
Day.StartTime.Hour = 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.

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.

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

<Data file>.<item>.Hour = <New time>
<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
During a direct assignment (for example, Day.StartTime.Hour = n), the time must be included between 0 and 23. A WLanguage error occurs if the specified time is invalid.
The notation Day.StartTime.Hour = Day.StartTime.Hour + 5 may generate an error at run time.
Case 2: Operations on times
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).
// Example on a variable
StartTime is Time = "2335"
StartTime.Hour++                            // StartTime = 0035
StartDate is Date = "202011262335"        // 11/26/2020 at 11:35 PM
StartDate.Hour++                             // 11/27/2020 at 12:35 AM

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 -=
// Example on an item
Day.StartTime = "1230"
Day.StartTime.Hour++     // Add 1 hour
Day.StartTime.Hour+=5    // Add 5 hours
Day.StartTime.Hour-=5    // Subtract 5 hours
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/20/2024

Send a report | Local help