How to: |
Available Languages: reporting, Maintain
The HPART function extracts a specified component from a date-time value and returns it in numeric format.
HPART(datetime, 'component', output)
where:
Date-time
Is the date-time value from which the component is to be extracted, the name of a date-time field that contains the value, or an expression that returns the value.
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.
Integer
Is the field that contains the result, or the integer format of the output value enclosed in single quotation marks.
HPART retrieves the day in integer format from the TRANSDATE field:
TABLE FILE VIDEOTR2 PRINT CUSTID TRANSDATE AS 'DATE-TIME' AND COMPUTE DAY_COMPONENT/I2 = HPART(TRANSDATE, 'DAY', 'I2'); WHERE DATE EQ 2000; END
The output is:
CUSTID |
DATE-TIME |
DAY_COMPONENT |
|
1237 1118 |
2000/02/05 03:30 2000/06/26 05:45 |
5 26 |
HPART extracts the day in integer format from DT1:
MAINTAIN FILE DATETIME FOR 1 NEXT ID INTO STK; COMPUTE DAY_COMPONENT/I2 = HPART(STK.DT1,'DAY',DAY_COMPONENT); TYPE "STK(1).DT1 = <STK(1).DT1"; TYPE "DAY_COMPONENT = <DAY_COMPONENT"; END