seqaPosix

Purpose

Creates a sequence of dates.

Format

dt_vec = seqaPosix(dt_start, inc, unit, n)
Parameters
  • dt_start (string or scalar) –

    contains the starting date as a string, date, or in POSIX date/time format (seconds since Jan 1, 1970).

    If string, valid formats include:

    • "YYYY-MM-DD HH:MI:SS"

    • "YYYY-MM-DD HH:MI"

    • "YYYY-MM-DD HH"

    • "YYYY-MM-DD"

    • "YYYY-MM"

    • "YYYY"

  • inc (scalar) – the number of units for each of the n increments.

  • unit (string) –

    indicating the units for the increments in inc.

    Valid unit options:

    • "years"

    • "months"

    • "days"

    • "hours"

    • "seconds"

  • n (scalar) – the number of elements to create.

Returns

dt_vec (nx1 dataframe) – starting at dt_start and increasing by inc units. The dt_vec will be in same date format as dt_start.

Examples

// Create a sequence of 10 dates separated by 4 years
dt_vec = seqaPosix("1980-01-20", 4, "years", 10);

The above code will set dt_vec equal to:

1980-01-20
1984-01-20
1988-01-20
1992-01-20
1996-01-20
2000-01-20
2004-01-20
2008-01-20
2012-01-20
2016-01-20
// Create a sequence of 6 dates separated by 30 minutes
dt_vec = seqaPosix("2003-03-17 05:30:00", 30, "minutes", 6);

The above code will set dt_vec equal to:

2003-03-17 05:30:00
2003-03-17 06:00:00
2003-03-17 06:30:00
2003-03-17 07:00:00
2003-03-17 07:30:00
2003-03-17 08:00:00
// Convert string date in a different format to
// a GAUSS date.
dt_start = strcToPosix("01/20/1980", "%m/%d/%Y");

// Create a sequence of 10 dates separated by 4 years
dt_vec = seqaPosix(dt_start, 4, "years", 10);

In the above example, dt_start is:

01/20/1980

This will set dt_vec equal to:

01/20/1980
01/20/1984
01/20/1988
01/20/1992
01/20/1996
01/20/2000
01/20/2004
01/20/2008
01/20/2012
01/20/2016