Noob question. I have a csv file with the following format
2019-04-18 08:29:47,ACE001P,QL.IN.XCENTER.ERECEIPT.FACADE,2
The date and time stamp goes back almost a month. Now I only want data for the last day's date, means 1 day old data. I am using below code, but it gives me no output.
$Data = Import-CSV "E:\Chayan\QL.IN.XCENTER.ERECEIPT.FACADE_ACE001P_1.csv"
$CutoffDate = (Get-Date).AddDays(-30)
$Data | Where-Object {$_.Date -as [datetime] -lt $CutoffDate} | Out-File .\QL.IN.XCENTER.ERECEIPT.FACADE_ACE001P_2.csv
I know I am doing something extremely stupid. Just need a way to make this work.
$_.Date).(Get-Date).AddDays(-30)should also be(Get-Date).AddDays(-1)for one day old data.