How can I get last month monday dates?

Hi All,

How can I get last month monday dates?
Current month is january. I need to pick up only those files which has last month monday date in the filename.

Please help.

Depending on some more details we could do:

grafik

  • creating a part of the filename representing last month
  • using this for the file retrieval

e.g.
Directory.GetFiles(YourFolderPath, "*" & now.AddMonths(-1).toString("MM-yyyy") & "*")

1 Like

I can only see month and year here.
for eg. filename is “Bank Accounts dd MMM YYYY.xlsx” where dd will be last month monday dates.
There will be 4 files (6 dec,13 dec,20 dec,27 dec) in the folder.

Ok, pattern apprioach would work for you
the Monday part I can add. Just give me a little time

1 Like

Variables:

Flow:
grafik

now.AddDays(- now.Day).Day

(From x In Enumerable.Range(0,DayCount)
Let d = now.AddDays(- now.Day + 1).AddMonths(-1).AddDays(x)
Where d.DayOfWeek = 1
Select m=d).toArray

grafik

Instead of LINQ you can also implementing it with essential activities (have a look also on repeat number of times for replacing Enumerable.Range)

Find starter help here:
GetLastMonthModays.xaml (4.8 KB)

1 Like

Thanks , I will try this.

Getting exception
GetLastMonthModays.xaml workflow.

you would need to execute the assign first before you can check it within immediate panel

Is arrLastMonthMondays defined as the correct array datatype?

Yes, It is defined as array of datetime one dimentional array.

Have you selected c# as UiPath language? I am writing in VB.

@Poonam_Yadav
Try This :
Now.AddMonths(-1).AddDays(-(Now.AddMonths(-1).Day)+30).DayOfWeek.ToString

Use a counter variable in place of 30.

I am still getting exception :worried:

xaml is done on VB

we would recommend to do this, as mentioned above. So set a breakpoint to the comment and remove other breakpoints.

Otherwise just open a new XAML in your project and redo the modeling as described

Maybe you can share with us:

  • Version / Edition of Studio
  • UiPath.System.Activities Version

Hi!

Have a view on this workflow its working fantastic.

Regards,
NaNi

Thank you very much Peter.
It’s working fine now. :smiley:

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