Function to obtain the value of the hour from the date/time variable.

 

Syntax

function HourOf(dt: double): integer;

 

Parameters and return values

Parameter

Type

Value

dt

double

date/time value from which you need to get the numeric value of hours.

 

Function result

The value of the hour of the day, from 0 to 23.

 

Example


var
  iHour: integer;
  s: string;
  dt: double;
begin
  dt := Now;
  iHour := HourOf(dt);
  
    if iHour < 12 then s := 'ante meridiem'
      else s := 'post meridiem';
  
  mLogScript(s + ' (' + FormatDateTime('hh:nn', dt) + ')', '');
end.


Script work result

[22:33:23] (Log "HourOf"): post meridiem (22:33)

 

See also

FormatDateTime

mLogScript

Now

Created with the Personal Edition of HelpNDoc: Achieve Professional Documentation Results with a Help Authoring Tool