The day of the previous month

I want to know the day of the 1st of the previous month.
For example, if it’s 2024/1 Monday .
If it’s 2024/2, Thursday.
If it’s 2024/3, it’s Friday
I want to know the day of the week whether it’s Monday, Tuesday or Saturday.

Hi @wjdehdnr456

Assign activity:
   CurrentDate = DateTime.Now

Assign activity:
   PreviousMonthFirstDay = CurrentDate.AddMonths(-1).AddDays(-CurrentDate.Day + 1)

Assign activity:
   DayOfWeekString = PreviousMonthFirstDay.DayOfWeek.ToString

Check the below workflow for better understanding,

Note - CurrentDate and PreviousMonthFirstDay is DateTime datatype Variable.

Or you can simply use in one assign activity,

DayOfWeekString = (DateTime.Now.AddMonths(-1).AddDays(-DateTime.Now.Day + 1)).DayOfWeek.ToString

Hope it helps!!

1 Like

Hi @wjdehdnr456

Can you try this

DateTime.Now.AddMonths(-1).AddDays(-(DateTime.Now.Day - 1)).DayOfWeek.ToString()

1 Like

Hey @wjdehdnr456
You can use:
New DateTime(Datetime.Now.Year, datetime.Now.Month, 1).AddMonths(-1)
firstDayPrevoiusMoth.DayOfWeek.ToString()


image

BlankProcess69.zip (2.3 KB)

1 Like

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