Get the last run of a month

I have a bot which runs every day multiple times.
My challenge is , on the last run of every month I have to create some folders.

Please help.

Hi @Ritaman_Baral,

First you need to identify the Last day of the current month.

Dim currentDate As DateTime = DateTime.Now
    Dim lastDayOfMonth As DateTime = New DateTime(currentDate.Year, currentDate.Month, DateTime.DaysInMonth(currentDate.Year, currentDate.Month))

    If currentDate.Date = lastDayOfMonth.Date Then
        Console.WriteLine("Current date is the last day of the month.")
    Else
        Console.WriteLine("Current date is not the last day of the month.")
    End If

Then based on the bot’s average execution time you can determine whether is the current job is the last one or not. You have to do a comparison of current time and job execution time

Check the attached workflow for more details

LastDayOftheMonth.xaml (8.0 KB)

Hello @Ritaman_Baral

Get current date
Assign currentDate = Now

Check if it’s the last day of the month
currentDay = currentDate.Day
daysInMonth = DateTime.DaysInMonth(currentDate.Year, currentDate.Month)

isLastDayOfMonth = (currentDay = daysInMonth)

If it’s the last day of the month, create folders
If isLastDayOfMonth Then
Create Directory: YourFolderPath1
Create Directory: YourFolderPath2
Add more Create Directory activities as needed
End

Thanks & Cheers!!!

1 Like

Main.xaml (7.6 KB)
Hope it helps you!

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