GetDatesCentered

This function evaluates to a list of datetimes, centered around a given date.

Description

Generate a list of datetimes separated by a given interval, and centered at a given date. If desired, dates not within the run duration are filtered out of the list.

Type

LIST {DATETIME}

Arguments

Type

Meaning

1

DATETIME

center datetime

2

NUMERIC

number of dates to return in the list

3

STRING

string representation of a datetime interval expressed as an integer, a space, and a time unit

3

BOOLEAN

whether to limit return dates to those within the run

Evaluation

The center datetime, which may be specified symbolically, is converted into an actual datetime. The string representation of the interval is resolved into a time length. Then a list is created with the given number of dates, each separated by the given time interval. The center date is always included in this list, with an equal number of dates appearing before and after it (in the case of an odd number of dates). If their are an even number of dates, then there is one more date appearing before the center date than appear after. After the list has been created, if the user has specified that they only want dates within the run duration, then all other dates are filtered out of the return list.

Mathematical Expression

 

Comments
The accepted datetime interval units are:
  • hours or Hour s
  • days or Days
  • weeks or Weeks
  • months or Months
  • years or Years
 
GetDatesCentered(@"January 20, 1996", 3, "6 Hours", true}
 
{@"18:00 January 20, 1996", @"24:00 January 20, 1996", @"06:00 January 21, 1996"}