How to get the file from previous year

Hi Team.

I need to pick the previous week wednesday file.
the folder structure is like 2022/01 January/01-05-2022.xlsx
Now I want to pick the file for previous week from 2021/01 January/12-29-2021.xlsx

and this situation arise only for the first wednesday in new year.
I was able to get the file name, but i am confused how to handle to go inside the year and month folder.

Can anyone help?

Hi @nagini.pragna ,

just sharing my thoughts. i assume you already have logic to get file name.

i think you are wrongly mentioned the folder path 2021/01 January/ . if you are looking for previous week file for the new year first Wednesday the folder structure would be 2021/12 December/ i guess.

Can we have if condition like below. Please try below logic and let us know. thanks.

FilePath1 = 2022/01 January/
FilePath2 = 2021/12 December/

if condition should be → now.Month = 1 AND now.Day <8 (always first wedenesday happening before 8 days in the new year)

Condition statisfies ->Now.tostring(“yyyy”)+“/”+Now.tostring(“MM”)+" “+Now.tostring(“MMMMM”)
Else Part → Now.Addmonths(-1).tostring(“yyyy”)+”/“+Now.Addmonths(-1).tostring(“MM”)+” "+Now.Addmonths(-1).tostring(“MMMMM”)

1 Like

Thanks for the reply. I will try and let you know

Your welcome.