I want to store the system date and time as a string to gdx when executing a script, preferably with a custom format.
I tried the following:
parameter
exec_date execution date
exec_time execution time
;
exec_date = '%system.date1%';
exec_time = '%system.time%';
However I get the following error message in the .lst file:
1 parameter
2 exec_date execution date
3 exec_time execution time
4 ;
5
6 exec_date = 'Dec 17, 2020';
**** $119,140,409
**** 119 Number (primary) expected
**** 140 Unknown symbol
**** 409 Unrecognizable item - skip to find a new statement
**** looking for a ';' or a key word to get started again
7 exec_time = '13:24:05';
**** $119,409
**** 119 Number (primary) expected
**** 409 Unrecognizable item - skip to find a new statement
**** looking for a ';' or a key word to get started again
The following snippet gives the same error message:
variable
exec_date execution date
exec_time execution time
;
exec_date = '%system.date1%';
exec_time = '%system.time%';
Finally, the following snippet runs without error:
$set exec_date = '%system.date1%';
$set exec_time = '%system.time%';
However it seems that both exec_date
and exec_time
are not dumped to gdx:
gams date gdx=date
Moreover, I tried to display exec_date
and exec_time
:
display
exec_date
exec_time;
However, I get the following error message in the .lst file:
21 display
22 exec_date
**** $140
**** 140 Unknown symbol
23 exec_time;
**** $140
**** 140 Unknown symbol
Is it possible to store the system date and time as a string to gdx?
Moreover, is it possible to format the date string as yyyy-mm-dd?
It can be implemented as set:
This outputs:
And is saved to gdx using