[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] 24x7 Script Archive


Converting dates to file names

When you need to calculate file name as a date you may use the following example as a template:

Dim today, date
Dim yesterday, date
Dim file_name, string

// Get today's date
Today( today )
// Calculate yesterday's date
DateAdd( today, -1, yesterday )
// Convert to string in mmddyyyy format
Format( yesterday, "mmddyyyy", file_name )
// Append file extension
Concat( file_name, ".dat", file_name )

// Do something with this file,
// for example FTP, Copy, Load into database, etc.
// ...

In some cases, you may simple use available macro-parameters. For example, the following script is functionally equal the script above:


Dim file_name, string

// Build file name
Concat( @DP"mmddyyyy", ".dat", file_name )

// Do something with this file,
// for example FTP, Copy, Load into database, etc.
// ...