How to get the date of the previous business day?

I have a string variable named ‘str_date’ which contains a date and time in the format of ‘20.12.2022 15:04:25’. How can I add 1 month to this date, and get the date of the previous business day? Can you provide a single assign statement for this?

1 Like

Hi

If this the date format then the below expression would help you resolve this

Str_date = Datetime.ParseExact(Strinput.ToString.SubString(0,10), “dd.MM.yyyy”, System.Globalization.CultureInfo.InvariantCulture).AddMonths(1).ToString

For more details on data time there is a tutorial in UiPath forum
Have a view on it for details on Datetime

Cheers @Betul_Dundar

@Betul_Dundar

Please try this

varDate = DateTime.ParseExact("20.12.2022 15:04:25", "dd.MM.yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture).AddMonths(1)

If(varDate.DayOfWeek = DayOfWeek.Monday, varDate.AddDays(-3), If(varDate.DayOfWeek = DayOfWeek.Sunday, varDate.AddDays(-2), varDate.AddDays(-1)))

image

Hope this helps

cheers

Hi @Palaniyappan , thank you for your response. But it gives me 1 month later. Not 1 month laters’ previous working day. I can not use marketplace now. I have to use just assign.

@Betul_Dundar

Try as below

  1. Declare a variable as

strDateTime = DateTime.ParseExact(“20.12.2022 15:04:25”, “dd.MM.yyyy HH:mm:ss”, CultureInfo.InvariantCulture)

now declare another variable as strOutput type of DateTime again

strOutput = Enumerable.Range(1,3).Select(Function(i) New DateTime(Today.Year,Today.Month,i).AddMonths(1)).Where(Function(d) d.DayOfWeek<>DayOfWeek.Sunday AndAlso d.DayOfWeek <> DayOfWeek.Saturday).First().Tostring

Hope this may help you

Thanks,
Srini

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