The dtextend() function

The dtextend() function extends a datetime value to a different qualifier. Extending is the operation of adding or dropping fields of a DATETIME value to make it match a given qualifier.

Syntax

mint dtextend(in_dt, out_dt)
   dtime_t *in_dt, *out_dt;
in_dt
A pointer to the datetime variable to extend.
out_dt
A pointer to a datetime variable with a valid qualifier to use for the extension.

Usage

The dtextend() function copies the qualifier-field digits of the in_dt datetime variable to the out_dt datetime variable. The qualifier of the out_dt variable controls the copy.

The function discards any fields in in_dt that the out_dt variable does not include. The function fills in any fields in out_dt that are not present in in_dt, as follows:
  • It fills in fields to the left of the most-significant field in in_dt from the current time and date.
  • It fills in fields to the right of the least-significant field in in_dt with zeros.
In the following example, a variable fiscal_start is set up with the first day of a fiscal year that begins on June 1. The dtextend() function generates the current year.
datetime work, fiscal_start;

work.dt_qual = TU_DTENCODE(TU_MONTH,TU_DAY);
dtcvasc("06-01",&work);
fiscal_start.dt_qual = TU_DTENCODE(TU_YEAR,TU_DAY);
dtextend(&work,&fiscal_start);

Return values

0
The operation was successful.
-1268
A parameter contains an invalid datetime qualifier.