How to: |
Available Languages: reporting, Maintain
The HNAME function extracts a specified component from a date-time value and returns it in alphanumeric format.
HNAME(datetime, 'component', output)
where:
Date-time
Is the date-time value from which a component value is to be extracted, the name of a date-time field containing the value 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.
Alphanumeric, at least A2
Is the field that contains the result, or the format of the output value enclosed in single quotation marks. The format must be in alphanumeric format.
The function converts a month argument to an abbreviation of the month name and converts and all other components to strings of digits only. The year is always four digits, and the hour assumes the 24-hour system.
HNAME returns the week in alphanumeric format from the TRANSDATE field. Changing the WEEKFIRST parameter setting changes the value of the component.
SET WEEKFIRST = 7 TABLE FILE VIDEOTR2 PRINT CUSTID TRANSDATE AS 'DATE-TIME' AND COMPUTE WEEK_COMPONENT/A10 = HNAME(TRANSDATE, 'WEEK', 'A10'); WHERE DATE EQ 2000; END
When WEEKFIRST is set to seven, the output is:
CUSTID DATE-TIME WEEK_COMPONENT ------ --------- -------------- 1237 2000/02/05 03:30 06 1118 2000/06/26 05:45 26
When WEEKFIRST is set to three, the output is:
CUSTID DATE-TIME WEEK_COMPONENT ------ --------- -------------- 1237 2000/02/05 03:30 05 1118 2000/06/26 05:45 25
For details on WEEKFIRST, see the TIBCO WebFOCUS® Developing Reporting Applications manual.
HNAME retrieves the day in alphanumeric format from the TRANSDATE field:
TABLE FILE VIDEOTR2 PRINT CUSTID TRANSDATE AS 'DATE-TIME' AND COMPUTE DAY_COMPONENT/A2 = HNAME(TRANSDATE, 'DAY', 'A2'); WHERE DATE EQ 2000; END
The output is:
CUSTID DATE-TIME DAY_COMPONENT ------ --------- ------------- 1237 2000/02/05 03:30 05 1118 2000/06/26 05:45 26
HNAME extracts the day in alphanumeric format from DT1:
MAINTAIN FILE DATETIME FOR 1 NEXT ID INTO STK; COMPUTE DAY_COMPONENT/A2=HNAME(STK.DT1,'DAY',DAY_COMPONENT); TYPE "STK(1).DT1 = "STK(1).DT1; TYPE "DAY_COMPONENT = <DAY_COMPONENT" END