You are here: Building Expressions > Dates and Times > Converting Dates with Computed Fields

Converting Dates with Computed Fields

When working with data that uses serial dates or that has different start of century dates within the same file or among several files, you can use computed fields to convert the data into a form that you can use for analysis.

Serial Dates

Dates are sometimes represented with a serial number. Serial date schemes represent the date as the number of days that have elapsed from some arbitrary base starting date, such as January 1, 1900. When you create a table layout, Analyzer recognizes the serial number as numeric data.

You can create a computed field in Analyzer that adds the serial number to an Analyzer date literal that contains the start or reference date. For more information on date literals see Date, Time and Elapsed Time Constants (Literals).

For example, if a serial date starts as day 0 on January 1, 1900 and the serial numeric field is named SDATE, you can create a computed field containing an expression, similar to the one shown below, to convert the serial numeric values into valid dates:

‘19000101‘ + SDATE

or

CTOD(19000101)+SDATE

If the start date is earlier than January 1, 1900, then the value will need to be adjusted to match Analyzer’s start date:

‘19000101‘ + (SDATE - Adjustment_Days)

Start of Century Date

Many data files use two digits to represent the year. The year used to denote the earliest date in the last century varies from one set of data files to the next. The two-digit year that indicates the oldest year in the last century is often called the start of century date or the pivot date.

The way that Analyzer reads two-digit years depends on your Start of Century preference setting. With the default setting of 40, Analyzer interprets the years 40 to 99 as 1940 to 1999 and the years 00 to 39 as 2000 to 2039. Analyzer uses this setting whenever it encounters data that uses two digits to represent the year in a table. It will not affect dates that use three or four digits to represent the year. To change the default setting, see Start of Century Date.