DATE

 

Introduction

The DATE command is used to assign a date value to a memory variable of date type.  

 

Syntax

DATE name = date ;

DATE name = expression ;

 

name

A memory variable (do not prefix with '#')

date

Dates can be years, quarters or months, for instance '2010', '2011q2' or '2012m11'.

expression

You may use expressions on the right-hand side. Gekko will try to convert to DATE if possible.

 

A DATE variable 'per1' can later on be referenced to by means of '#per1' or '{per1}'. For dates, the former variant is typically preferable.

 

 

Example

You may use simple additions/subtractions in the option field, when referring to these dates. For instance

 

PRT <#per1-2 #per1+1> fY;

 

You may wish to use dates to control the flow of your system of command files, centralizing the assignment of dates in one place.

 

DATE per1 = 2012;

DATE per2 = 2040;

READ lang11;

UPD <#per1 #per1> JDfVmo + 1000;

SIM <#per1 #per2>;

MULPRT <#per1-1 #per2> fY;

 

Conversions are possible:

 

STRING s1 = '2010';

VAL v1 = 2015;

DATE d1 = #s1;

DATE d2 = #v1;

TIME #d1 #d2;

 

The conversion will fail if not possible (for instance the string '201o' or val 2015.4). If you need to explicitely convert to a date (for instance inside an expression), you may use the DATE() function.

 

CREATE data;

FOR date d = 2010 to 2015;

 UPD <#d #d> data = val(#d)-2000;

END;

 

Here, an explicit conversion from the #d variable is done. The result is this:

 

                data

 2010        10.0000

 2011        11.0000

 2012        12.0000

 

 

 

Note

Dates are memory variables, and in this respect similar to strings and values (see STRING and VAL).

 

 

Related

commands

STRING, VAL, FOR, IF, TIME