RndFormatDate Function

Action

Adds a random number of days between 0 and nDays to a date and formats this date into the specified format. The random values generated are distributed uniformly.

Include file

Kernel.bdh

Syntax

RndFormatDate( in nDate      : number,
               in nDays      : number,
               in sFormat    : string
               in bLocalized  : boolean optional ): string;

Return value

formatted date string

Parameter Description
nDate Input date with format YYYYMMDD
nDays Upper boundary of random interval for days to add
sFormat Format control string (FormatDate)
bLocalized If True, returns the localized date format (optional).

Example

dcltrans
  transaction TRndFormatDate
  var
    sNewDate: string;
  begin
    // add 0 - 20 days to 19961015 and format it to "1996-11-10"
    sNewDate := RndFormatDate(19961015, 20, DATE_YYYY_MM_DD);
    write("newdate = "); write(sNewDate); writeln;
  end TRndFormatDate;

Output

newdate = 1996-10-30

Sample scripts

OraSample.bdf, DBApi01.bdf