Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add all dates in between two dates to array in powershell

I'm trying to figure out how to add all the dates between 08/27/14 to 10/27/14 to an array in the yyyyMMdd format. Can someone please point me in the right direction.

like image 953
user1800738 Avatar asked Jan 29 '26 21:01

user1800738


1 Answers

Thanks guys, as always once I posted on the forum an idea pops into my head. This seems to work for what I need.

$startDate = Get-Date 08-27-14
$endDate = Get-Date 10-27-14
while($startDate -le $endDate){
$nextDate = Get-Date $startDate -format yyyyMMdd
write-host $nextDate
$startDate = $startDate.AddDays(1)
}
like image 106
user1800738 Avatar answered Feb 01 '26 10:02

user1800738



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!