Convert date to week number


I want to convert a date to a week number. This is commonly done in Sweden. Currently today’s date (16 July 2017) is week 28. In UiPath, under System.Globalization I find a .net type called ‘CalendarWeekRule’. Is this something I can use to pipe a date into a variable and display it as a week number? Any help much appreciated. Thanks.


Hey @sterner

You can use this to get week number

int week_number = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(new DateTime(2013, 12, 31), currentCulture.DateTimeFormat.CalendarWeekRule,currentCulture.DateTimeFormat.FirstDayOfWeek)

But as you mentioned

Above is not ISO 8601 compatible. In Sweden You guys use ISO 8601 week numbers but even though the culture is set to “sv-SE”, CalendarWeekRule is FirstFourDayWeek, and FirstDayOfWeek is Monday the weekNo variable will be set to 53 instead of the correct 1 in the above code.

Check it on google. you will easily get the things related with this.

Check this attached workflow and let me know :slight_smile:
weeknumber.xaml (6.3 KB)



Thanks @aksh1yadav for replying so quickly. Your sample code worked fine. I’ll have a look at the msdn article also. Cheers, Tomas