<< back to sysax.com Product page

14.2. Formatted Timestamps

The formattimestamp command enables timestamps to be represented in multiple formats. The same year, month, date, hour, minute, or second values are still used, but they are arranged in different ways like MM/DD/YYYY or MM-DD-YY. The command takes a timestamp format string as input and generates the corresponding timestamp. An existing timestamp in the default YYYYMMDDhhyyss format that was previously generated using the gettimestamp command can also be used passed as an input to the formattimestamp command. If no timestamp is passed in, the current timestamp value is automatically generated and used.

The following values in the format string are replaced with the corresponding timestamp values:

%YYYY%   - replaced by the 4 digit year
%YY%        - replaced by the 2 digit year
%MM%       - replaced by the 2 digit month
%DD%        - replaced by the 2 digit day
%hh%          - replaced by the 2 digit hour
%mm%        - replaced by the 2 digit minute
%ss%          - replaced by the 2 digit second

Exhibit 14.3. Syntax of the formattimestamp command

formattimestamp <user variable>, <format string> [, optional: <timestamp in YYYYMMDDhhmmss format>];

Exhibit 14.4. Example of using the formattimestamp command

formattimestamp ~mytimestamp, "%MM%-%DD%-%YY%", "20090201092130"; #output generated is 02-01-09

formattimestamp ~mytimestamp, "%MM%-%DD%-%YY%"; #the current timestamp is generated in MM-DD-YY format