How to: |
Available Languages: reporting, Maintain
The HSETPT function inserts the numeric value of a specified component into a date-time value.
HSETPT(datetime, 'component', value, length, output)
where:
Date-time
Is the date-time value in which to insert the component, 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 inserted enclosed in single quotation marks. See Arguments for Use With Date and Time Functions for a list of valid components.
Integer
Is the numeric value to be inserted for the requested component, the name of a numeric field that contains the value, or an expression that returns the value.
Integer
Is the length of the returned date-time value. Valid values are:
Date-time
Is the returned date-time value whose chosen component is updated. All other components are copied from the source date-time value.
Is the field that contains the result, or the format of the output value enclosed in single quotation marks. The format must be in date-time format (data type H).
HSETPT inserts the day as 28 into the ADD_MONTH field and stores the result in INSERT_DAY:
TABLE FILE VIDEOTR2 PRINT CUSTID TRANSDATE AS 'DATE-TIME' AND COMPUTE ADD_MONTH/HYYMDS = HADD(TRANSDATE, 'MONTH', 2, 8, 'HYYMDS'); INSERT_DAY/HYYMDS = HSETPT(ADD_MONTH, 'DAY', 28, 8, 'HYYMDS'); WHERE DATE EQ 2000; END
The output is:
CUSTID DATE-TIME ADD_MONTH INSERT_DAY ------ --------- --------- ---------- 1118 2000/06/26 05:45 2000/08/26 05:45:00 2000/08/28 05:45:00 1237 2000/02/05 03:30 2000/04/05 03:30:00 2000/04/28 03:30:00
HSETPT inserts the day into ADD_MONTH:
MAINTAIN FILE DATETIME FOR 1 NEXT ID INTO STK; COMPUTE ADD_MONTH/HYYMDS = HADD(STK.DT1,'MONTH', 2, 8, ADD_MONTH); INSERT_DAY/HYYMDS = HSETPT(ADD_MONTH,'DAY', 28, 8, INSERT_DAY); TYPE "STK(1).DT1 = <STK(1).DT1"; TYPE "ADD_MONTH = <ADD_MONTH"; TYPE "INSERT_DAY = <INSERT_DAY"; END