Get last date previous month?

If today = first date in month (Working Day)
I want to get last date previous month

Example1 : If today = 02/08/2021 ( First Date in month that Working Day and not public holiday)
I want to get 31/07/2021

Example2 : If today = 04/09/2021 [First Date in month that Working Day because 01/09/2021 - 03/09/2021 in public holiday (check public holiday from file excel)]
holiday.xlsx (8.0 KB)


I want to get 30/08/2021

Remark working day mean Monday-friday

Please guide me about it.


You can get last date. Use assign activity with datetime variable.

New datetime(now.Date.Year, now.Date.Month,1).AddDays(-1)

@ghazanfar I​ want​ use​ condition​ for​ check​ date​
if​ today​ = first​ day​ (In​ working​ day)
I​ want​ assign​ date2 =​ last​ date​ previous​ month

then​ date2​ = today

Hi You can use this workflow. I created 1 excel files which contains holidays date bot will first get the todays date then will check whether it is weekend or working day if it is not sunday or saturday then it will check whether it is public holiday or not by comparing it with excel sheet (Holidays workbook) then it will calculate last date of previous month from today. (8.1 KB)

@ghazanfar No.

If today = 02/09/2021 and working day first date in month.
Because 01/09/2021 have public holiday.
I want to output = 31/08/2021

If today = 03/09/2021. It not first date in working date in month.
I want output = 03/09/2021

Remark: If not first week of month and not first date working in month → output = today

Please guide me more for solve it.

Hi ,

I got your point, just modified the previous code I also added comments in the code for understanding as well. let me know if you need more information. (10.1 KB)

1 Like

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