Set filename regarding current month

Hi all,

I am working currently on a robot who is downloading an excel file from SAP and saving it in a specific place.

The file should have this name: “Target hours_FY23_P05.xlsx”.

Now i want to create a dynamic variable for the “P05”. The logic is that the month October is P01, November P02, December P03 and so on.
The bot should check which date we actually have when downloading the file (for example: 14.02.2023 → February → P05) and then save it.

Any ideas how to approach this case?

Thank you!

Hi @motorlab_9

You can use switch case activity for all the months and if particular months comes we will be in that case and you can set the file name according to that particular month. Hope this helps you

Regards
Naman Jain

Hey

you have two ways there,

first you can create a list of string, starting with the value of january (it should be P04), and assing each value in order until you reach the december value, your array should contain 12 values.

then based on the month number just retrieve that position minus 1 (because array starts from 0 and months from 1) from your array like this
image

yourList(CInt(Now.Month - 1))

then just pass this value to your dynamic path

the other way is like @Naman_Jain suggest above, just create switch case activity and pass each corresponding value

hope this helps

Regards

I would first make a dictionary variable with the keys with each month and their corresponding “PXX” value. Like this:

dict_Months = New Dictionary(Of String, String) From
{
{“October”, “P01”},
{“November”, “P02”},


}

Then your filename will look like this:

str_Filename = “Target hours_FY23_”+dict_Months(Now.ToString(“MMMM”))

I think that will work.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.