HPART: Retrieving a Timestamp Date or Time Component as Numeric Value

How to:

The HPART function extracts a specified component value from a timestamp, in date-time format, and returns it in numeric format.


Top of page

x
Syntax: How to Retrieve a Timestamp Date or Time Component as a Numeric Value
HPART(value, component, output_format)

where:

timestamp

Date-Time

Is the timestamp from which a component value is to be extracted.

component

Alphanumeric

Is the name of the component to be incremented. For a list of valid components, see Date and Time Components For Date and Date-Time Functions.

output_format

Integer



Example: Retrieving a Timestamp Date or Time Component as Numeric Value

Assuming that the current time obtained by HGETC in the first parameter is 14:01:39, this example returns a whole number, 14, and assigns it to IHOUR:

IHOUR/I2 = HPART(HGETC(8,'HYYMDS'),'HOUR', IHOUR);  

iWay Software