Im trying to make a calendar program with powershell using PSExcel and im trying to do it for any given year from 2000 to 2100. Not sure how i would exactly find the start date for any given year. Any tips?
Thanks!
Im trying to make a calendar program with powershell using PSExcel and im trying to do it for any given year from 2000 to 2100. Not sure how i would exactly find the start date for any given year. Any tips?
Thanks!
It’s a little unclear what you’re looking for. You could generate a DateTime object for the first of January for each year doing something like this …
$years = 2000..2100 foreach ($yr in $years) { Get-Date -Day 1 -Month 1 -Year $yr -Hour 0 -Minute 0 -Second 0 }
It’s always been January 1st:-)
(1991…2015) | % {[datetime]“1/1/$_”}
I assume he means start day (Day of week) vs the actual date of Jan 1
In case that is what is needed, quick/dirty single day of week retrieval, just pass it a date (1-1-2016 for instance) and get the DayOfWeek property:
get-date 1-1-2016 | select -expandProperty DayOfWeek
easy.
(1991…2015) | % {([datetime]“1/1/$_”).dayofweek}