Special Handling of Date Values

Revision as of 21:01, 17 December 2014 by Psanford (talk | contribs)

Analytica includes group of Date Functions specifically designed to create and manipulate date values. But there are also some common functions which, although they are typically applied to standard numerical values, include optional parameters to handle dates. This page links to all functions that handle dates.

The dateUnit Parameter

The dateUnit parameter is available in several rounding functions. It must be called explicitly and replaces the digits parameter.

Functions that use the dateUnit parameter:

dateUnit values include: - 'Y' for Year - 'Q' for Quarter - 'M' for Month - 'WD' for Weekday - 'D' for Day - 'h' for Hour - 'm' for minute - 's' for second

Note that Month and minute are distinguished by case.

Examples
Round up to the next year: Ceil(MakeDate(2014, 12,17), dateUnit: 'Y') → 1-Jan-2015
Round to the nearest top of the minute: Round(Now(withTime:1), dateUnit: 'm') → 17-Dec-2014 11:32:00 AM
List the next 5 Groundhog Days: Sequence(MakeDate(2015,2,2), MakeDate(2019,2,2), dateUnit: 'Y')
→ [2-Feb-2015, 2-Feb-2016, 2-Feb-2017, 2-Feb-2018, 2-Feb-2019]

Creating Dates

It is possible to create a date value without help from any function. A value will be recognized as a date if it follows the syntax dd-EEE-yyyy

Where:

dd is one or two digits for day of month

EEE is a three character text code for the month in the default language set in the OS. (English in the example below)

yyyy is four digits for the year

Example
04-DEC-2015

The bare date syntax must be used on its own. It cannot be embedded within an expression.

To explicity define a date you can use one of the following functions:

Importing Dates

DbQuery() and SpreadsheetRange() can import date values into Analytica. Both recognize date type values in the source data.

By default, DbQuery does not convert these to dates when importing but you can change this preference using the DatesAsText parameter. More details here.

SpreadsheetRange() always preserves date values when they are imported. There are no optional parameters to think about in this case.

Dedicated Date Functions

The section above summarized special handling of dates using multi-purpose functions. Dedicated date functions are documented on the Date Functions page.

Comments


You are not allowed to post comments.