Using a timestamp as part of a filename 2021-01-26.CSV

Timestamps are typically used for logging events or in a sequence of events (SOE), in which case each event in the log or SOE is marked with a timestamp. Especially useful when using Yarado in batch processing running tasks via Orchestrator every 15 minutes or another time interval.

Yarado offers multiple system variables out of the box. These are accessible via Help --> Show system variables
image



This will display all available system variables including %TIMESTAMP% variables

System Variable Value
%TIMESTAMP HHMMSS% 144946
%TIMESTAMP HH-MM-SS% 14-49-46
%TIMESTAMP YYYYMMDD% 20210106
%TIMESTAMP YYYY-MM-DD% 2021-01-06
%TIMESTAMP YYYYMMDDHHMMSS% 20210106144946
%TIMESTAMP YYYY-MM-DD-HH-MM-SS% 2021-01-06-14-49-46

:warning: Yarado timestamps are formatted to be sorted in alphabetical order within Windows Explorer

image


In this Example, 1- first the timestamp is stored in the variable %timestamp%, 2- then a directory is created with timestamp as foldername, 3- Within this directory the file results.csv is created or appended with the results. The exact time is appended per line for logging purposes.



  1. As with normal variables, system variables can be used by typing the variable name in any input / step / edit box. When the step is processed the value is Replaced with the current date and time format. The System Variable function can be used to capture the current time (Now) into a variable for later use.



  1. Create a subdirectory within the task directory with the current the date and time

image


  1. Place log files within the directory for governance purposes

2 Likes

Very useful when running multiple subtasks using the same files from that specific location. After a main task is completed, I rename the location using RENAME command. If completed, the directory is renamed from %TIMESTAMP YYYYMMDD% to %TIMESTAMP YYYYMMDD%RUN%TIMESTAMP HHMM%. This is usefull if your run your maintask multiple times a day and want to separate the results. The result will occur e.g. \20200108RUN0908\

At the beginning of the maintask I check if the %TIMESTAMP YYYYMMDD% already exists, if this is the case a job was aborted unexpectedly, in this case I rename the directory to %TIMESTAMP YYYYMMDD%BROKEN%TIMESTAMP HHMM% and run the rest of the normal task, by starting with the creation of the new timestamp directory.

Als see best practices Using relative paths %Taskpath% to make tasks exchangeable

2 Likes