Start a new topic

Calculated Variable as Suffix in Filename

 Dear Team,

I'm trying to put the value of the last month as a suffix in my filename.

Please could you tell me if it's possible to do that in DbVis ?

For example :

${last_month} = DATE_FORMAT(add_months(CURRENT_DATE, -1),'MMyyyy');

@export ON;
@export SET Filename= "C:\Desktop\sales_${last_month}.csv";

SELECT * FROM table_sales WHERE  date_val <= add_months(CURRENT_DATE, -1);

export OFF;

Thank you in advance for your help.

Kind Regards,


You can use the predefined ${dbvis-date}$ variable to set current date in the file name.
For example:
@export SET Filename= "C:\Desktop\sales_${dbvis_date}$.csv";

The date can also be formatted:

@export SET Filename= "C:\Desktop\sales_${dbvis_date||||||format=[MMyyyy]}$.csv";

Read more about variables and predefined variable in



Hello @Ove Näslund ,

I already see this solution, unfortunatelly it does not give the expected result.

Please could you tell me if we can display the previous month value depending on the current date.

Thank you in advance for your help !

Best Regards



Hi BH,

Sorry, I missed that you wanted to set the previous month.

Unfortunately there is no way to set a variable - I will add this as a suggestion for improvement.

If you are using this in script you can as a work around use an environment variable and use this variable in the file name e.g. for the variable LAST_MONTH 

@export SET Filename= "C:\Desktop\sales_${env.LAST_MONTH}$.csv";



Login or Signup to post a comment