Hi I’m trying to create a variable that can return the ISO Week number of the Current Date
I thought using the following formula would work
ISOWeek.GetWeekOfYear(DateTime.Now)
But I get an error message "ISOWeek is not delared…
I also tried just GetWeekOfYear(DateTime.Now), but I get the same message.
Is there a simple way of achieving this?
ppr
(Peter Preuss)
March 27, 2021, 2:20pm
2
@CRETE_Thierry
ISOWeek.GetWeekOfYear is available for .net5 but not within the infrastructure that we do use with UiPath
for getting the week number have a look here:
@jahidKM
lets do following:
lets split the 03.2021 into year and week
[grafik]
init the first Year day, calculate the offset to the first friday of the year
[grafik]
retrieve the week offset (same week or next week)
[grafik]
So we can do the final calculation
[grafik]
Find starter help here
GetFriday_FromWeekNo.xaml (7.1 KB)
in .Net 5 a function for this was added, but unfortunately we cannot use it, as we do run via different infrastructre (.Net Framework)
reference:
some parameters in action:
1 Like
So are you saying “THERE IS NO SOLUTION”
or your telling me:
ISOWeek.GetWeekOfYear does not work in UiPath
BUT… Calendar.GetWeekOfYear… will work ?
ppr
(Peter Preuss)
March 27, 2021, 4:11pm
4
Was never and nowhere mentioned. And with a provided alternate its feasability was shown.
ISOWeek.GetWeekOfYear - not available in .Net framework 4.6.1
Calendar.GetWeekOfYear - we get it work
on how to do you can refer on provided links
1 Like
Thanks for the clarification.
So I changes my formula in my variable to the following:
Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Monday)
I still get the same “is not delared” error message.
What Am I doing wrong?
I’ve also tried adding the CultureInfo… prefix
Also tried changing DateTime.Now to Date.Now.
I thought this part of my automation was going to be so simple!!