Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to grab rows that have column values that are within the first 14 days starting from the earliest date and delete all rows otherwise

$
0
0

Hi guys, do you know how to grab rows that are within the first 14 days starting from the earliest date (which is Sept 13th to Sept 27th, but I want my script to be programmed so from the earliest date to 14 days later will be run no matter what the earliest date is). Because the column Planned Start Date have values that consists of all dates.

$days = (Get-Date).AddDays(-14)
Import-CSV -path 'C:\Temp\Excel6.csv' | Where-Object [DateTime]$_.'Planned Start Date' -le $days } 
| Export-CSV -path 'C:Temp\Excel6.csv -NoTypeInformation

But its output nothing of value and the result is a blank spreadsheet? Any way I can fix this? Thanks!


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>