User Guide Cancel

Hour

 

Description

Gets the current hour of the day.

Returns

Ordinal value of the hour, in the range 0-23.

Category

Date and time functions

Function syntax

Hour(date)
Hour(date)
Hour(date)

See also

DatePartMinuteSecond

Parameters

Parameter

Description

date

Date/time object, in the range 100 AD-9999 AD.

Usage

When passing a date/time value as a string, enclose it in quotation marks. Otherwise, it is interpreted as a number representation of a date/time object.

Example

<cfscript>
curdatetime = now();
curhour = hour(curdatetime)
writeOutput("The current hour is " & curhour & "<br/>");
</cfscript>
<cfscript> curdatetime = now(); curhour = hour(curdatetime) writeOutput("The current hour is " & curhour & "<br/>"); </cfscript>
 <cfscript>
     curdatetime = now();
     curhour = hour(curdatetime)
     writeOutput("The current hour is " & curhour & "<br/>");
 </cfscript>

Output

The current hour is 5

Get help faster and easier

New user?