hour
Table of Contents
Overview
The hour function takes a date-time or time value and returns the hour value.
Note:
- The date-time value will be returned in the format specified in application settings.
- the getHour function for time data-type is available only for Zoho Creator as of now.
- the hour function for time data-type is not available as of now.
Return Type
- NUMBER
Syntax
<variable> = <dateTimeValue>.hour();
(OR)
<variable> = hour(<dateTimeValue>);
(OR)
<variable> = <timeValue>.hour();
(OR)
<variable> = hour(<timeValue>);
(OR)
<variable> = <dateTimeValue>.getHour();
(OR)
<variable> = getHour(<dateTimeValue>);
(OR)
<variable> = <timeValue>.getHour();
(OR)
<variable> = getHour(<timeValue>);
where,
Parameter | Data type | Description |
<variable> | NUMBER | Variable which will contain the hours returned. |
<dateTimeValue> (if the value is date-time) | DATE-TIME | The date-time value from which the hours component should be obtained. The date-time value can be specified without a time value, in which case 00:00:00 will be taken as the default time value. If the hour value is specified as 24 or more, the date-time value be reset to 00:00:00. If the minutes value is specified as 60 or more, the mm:ss value will be reset to 00:00, if the seconds value is specified as 60 or more, the ss value will be reset to 00. A runtime error will be encountered if:
Refer date-time data type to learn more about date-time data type. |
<timeValue> (if the value is time) | TIME | The time value from which the hours component should be obtained. Time data type is currently supported only in Zoho Creator TIME values are represented in the formats - hh:mm:ss a (12-hour format) and HH:mm:ss (24-hour format) A runtime error will be encountered if:
Refer time data type to learn more about time data type. |
Examples
Date-Time Examples:
currentDate = '01-Jan-2019'; info currentDate.getHour(); // Returns 00
currentDate = '01-Jan-2019 23:15:10'; info currentDate.hour(); // Returns 23
Time Examples (Only for Creator):
timeValue = '10:00:00 PM'; info timeValue.getHour(); // Returns 10
currentTime = '13:15:10'; info currentTime.getHour(); // Returns 13