Last active
June 4, 2017 08:44
-
-
Save AlexSen/fe75c7a086b518a92879d3b4736cb598 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Get-DatesByWeekNumber | |
| { | |
| param( | |
| [int]$year = (Get-Date).Year, | |
| [int]$weekOfYear = (Get-Date -UFormat %W) | |
| ) | |
| # Get 1st of january of given year | |
| $jan1 = Get-Date("$year-01-01") | |
| $DateFrom = $jan1.AddDays( ( - (6 + $jan1.dayofweek.value__)%7 ) + ($weekOfYear * 7) ) | |
| $DateTo = $jan1.AddDays( ( - (6 + $jan1.dayofweek.value__)%7 + 6) + ($weekOfYear * 7) ) | |
| return @{ | |
| DateFrom = $DateFrom | |
| DateTo = $DateTo | |
| WeekNumber = $weekOfYear | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment