How to create Multiple folders with last moth dates

Hi team,
EVeryday i have to save last month excel files which is downloaded from SAP and save it in folders which should be named with last month dates, i.e have to create 30 folders with names like
01-03-2021
02-03-2021
03-03-2021 etc untill 28-03-2021. how can i build this logic and is it possible to share expression for this act.

@balaji.S - Please try like this…

startDate = Convert.ToDateTime(New DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month-1, 1))

endDate = Convert.ToDateTime(New DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month-1, System.DateTime.DaysInMonth(System.DateTime.Now.Year, System.DateTime.Now.Month-1)))

Here startDate and EndDate are of variable type “DateTime”

For Each

Create Folder
“LastMonthFolders” + item.ToString(“dd-MM-yyyy”)

My Output

Hope this helps…and I took the idea from @sarathi125 solution…credit goes to him…

2 Likes

@prasath17 many thanks for your efforts , this is absolutely working fine.

1 Like

Hearty thankful for sharing knowledge @sarathi125,

1 Like

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