Welcome Guest! Log in

It is a common need to use system timestamps, and there is a variety of ways to use them, regarding:

- which timestamp is needed : the date/time at which the current session started, or the current real date/time

- how it is going to be used : as an insert value, as a timestamp in a filename, as a test condition...

This article shows some examples on how to use date/times in Stambia.

Session begin date / time

The date/time when the session started is stored in the CORE_BEGIN_DATE variable. You can consult it in the "Session details" view:



This variable can be used in any process, or mapping, or property in this way: ${/CORE_BEGIN_DATE}$

See the target field "mdate" in this mapping:



Begin and End dates of actions

It is possible to refer to the variable CORE_BEGIN_DATE or CORE_END_DATE of every action.

Just refer to the action path in the process. For example ${/ActionName/CORE_BEGIN_DATE}$ or ${/SubProcessName/ActionName/CORE_BEGIN_DATE}$

Sample process

In this example, we have four actions.

- SomeAction, Sleep and Sleep (2): no matter what they do, it is just for having a few actions that we can refer to in "printDates"

- printDates: this scripting action shows a few examples of how to use dates.

Notice how we used a relative path to refer to other actions, in variable names.



Here is a sample output of the Runtime running this process:

18/06/2014 10:53:19,299 - timestamp (c0a84bc50146ae2e291d654770c04166) is started
Session started at:     2014/06/18 10:53:19.299
beginDate is:           2014/06/18 10:53:19.299
psDatetime is:          2014/06/18 10:53:19.309
SomeAction started at:  2014/06/18 10:53:19.312
Sleep started at:       2014/06/18 10:53:19.337 and stopped at: 2014/06/18 10:53:22.338
Sleep (2) started at:   2014/06/18 10:53:22.341 and stopped at: 2014/06/18 10:53:23.344
Current date-time is:   2014/06/18 10:53:23.370
18/06/2014 10:53:23,406 - timestamp (c0a84bc50146ae2e291d654770c04166) is ended


Naming a file with the current date/time

Consider the following file. Its physical name is timestamped with a function which will be replaced at execution with the current date/time.



If we have a simple mapping like this one:



Then the generated file will ben named like "nameWithTimestamp_20140618-113523-305.txt".

Note: if you execute this same mapping several times in the same process:



... then two different files will be generated:




You have no rights to post comments


Suggest a new Article!