Get Week of the Month

Hi,

Im trying to get week of the month.
For example:
30 July - 5 August, result is 1st week of August.
6 august - 12 august , result is 2nd week of august.
the week will be counted from Monday to sunday.
Any way can do so?

Look here

you can reproduce similar logic in UiPath.

@yjunkang
// variable type of in_Today DateTime (this will be your input datetime)
// variable type of Basedate is DateTime
// variable type of week is Int64

Assign Basedate = new DateTime(in_Today.Year, in_Today.Month, 1)
Assign week = DateAndTime.DateDiff(DateInterval.WeekOfYear ,Basedate, in_Today, FirstDayOfWeek.Monday,FirstWeekOfYear.Jan1)
actual value = week+1

2 Likes

Math.Ceiling(Now.Day/ 7)

This will give you the exact week of the month
from 1 to 7 first week,
from 8 to 14 second week,
from 15 to 21 third week,
from 22 to 28 fourth week and 29, 30 and 31 5th

1 Like

Agree with this solution