%SUBDT (Extract a Portion of a Date, Time, or Timestamp)

%SUBDT(value:*MSECONDS|*SECONDS|*MINUTES|*HOURS|*DAYS|*MONTHS|*YEARS)
%SUBDT(value:*MS|*S|*MN|*H|*D|*M|*Y)

%SUBDT extracts a portion of the information in a date, time, or timestamp value. It returns an unsigned numeric value.

The first parameter is the date, time, or timestamp value.

The second parameter is the portion that you want to extract. The following values are valid:

For this function, *DAYS always refers to the day of the month not the day of the year (even if you are using a Julian date format). For example, the day portion of February 10 is 10 not 41.

This function always returns a 4-digit year, even if the date format has a 2-digit year.

For more information, see Date Operations or Built-in Functions.

Figure 257. %SUBDT Example
 *..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
 /FREE

     date = d'1999-02-17';
     time = t'01.23.45';

     num = %subdt(date:*YEARS);
     // num = 1999

     num = %subdt(time:*MN);
     // num = 23
 /END-FREE


[ Top of Page | Previous Page | Next Page | Contents | Index ]