HPART: Retrieving a Date-Time Component as a Numeric Value

How to:

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


Top of page

x
Syntax: How to Retrieve a Date-Time Component in Numeric Format
HPART(datetime, 'component', output)

where:

datetime

Date-time

Is the date-time value from which the component is to be extracted.

component

Alphanumeric

Is the name of the component to be retrieved enclosed in single quotation marks. For a list of valid components, see Arguments for Use With Date and Time Functions.

output

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