setColDateFormats

Purpose

Specifies how GAUSS should display dates using the BSD strftime format specifiers. Note that this will also convert the type of the columns specified by column to Date.

Format

x_date = setColDateFormats(X, fmt, columns)
Parameters:
  • X (NxK matrix or dateframe) – data.
  • fmt (Mx1 string array) – contains strftime date/time format characters.
  • columns (Mx1 scalar or string) – The names or indices of the date columns in X to set format of.
Returns:

x_date (NxK dataframe) – contains metadata assigning the date display format specified by fmt to the variables in x specified by columns.

Examples

// Load data
fname = getGAUSSHome $+ "examples/xle_daily.xlsx";
xle = loadd(fname, "date(Date) + Volume");

// Print the first 2 observations
print "Dates in original format:";
print xle[1:2,.];

// Set date format to month/day/Year
xle_2 = setcoldateformats(xle, "%m/%d/%Y", "Date");

// Print the first 2 observations
print "";
print "Dates in new format:";
print xle_2[1:2,.];

The above code will print out:

Dates in original format:
            Date          Volume
      2017-06-13        15807900
      2017-06-14        30280200

Dates in new format:
            Date          Volume
      06/13/2017        15807900
      06/14/2017        30280200

Remarks

You can find a list of the available date format specifiers in the Command Reference entry for posixtostrc().

See also

Functions setColtypes(), getColDateFormats()