HSETPT: Inserting a Component Into a Date-Time Value

How to:

Available Languages: reporting, Maintain

The HSETPT function inserts the numeric value of a specified component into a date-time value.


Top of page

x
Syntax: How to Insert a Component Into a Date-Time Value
HSETPT(datetime, 'component', value, length, output)

where:

datetime

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.

component

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.

value

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.

length

Integer

Is the length of the returned date-time value. Valid values are:

8 indicates a time value that includes one to three decimal digits (milliseconds).

10 indicates a time value that includes four to six decimal digits (microseconds).

12 indicates a time value that includes seven to nine decimal digits (nanoseconds).

output

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).



Example: Inserting the Day Component Into a Date-Time Field (Reporting)

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


Example: Inserting the Day Component Into a Date-Time Field (Maintain)

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

WebFOCUS