stevenvd
(stevenvd)
1
This is rather an addition to this closed topic (Convert date to week number), than a real question. But it might help some people.
The idea is I want to create a variable that simply is the week of the year, so an integer between 1 and 53.
The solution posted below still yields an error when you haven’t referred to CultureInfo before.
The full solution should be:
System.Globalization.CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(System.DateTime.Now, System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule,System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek)
10 Likes
Thanks stevenvd, Very useful 
Is it possible to have the “firstDayOfWeek” Using the above formula ? Thx in advance
stevenvd
(stevenvd)
3
What exactly are you looking for? The date of the first day of the current week?
Thanks Stevenvd, I have already fixed the issue : ```
Get-ItemProperty -Path ‘HKCU:\Control Panel\International’| Select-Object iFirstDayOfWeek
Get-ItemProperty -Path 'HKCU:\Control Panel\International'| Select-Object iFirstDayOfWeek
1 Like
Hello @stevenvd
Thank you for your post!
That way the week starts on sunday. Is there any way that the week starts on monday?
Thank you in advance 
Try this:
Assign Math.Ceiling(DateTime.Now.DayOfYear / 7).ToString() to weekNumber
U can just get rid of the .ToString