I've got my dates in a JSON file in sortable (-s). The first is:
"DTSlocal": "2012-11-10T08:09:35"
This is 10th November 2012 at 08:09:35 (local)
When I load the file and convert from JSON (new object = $data), PowerShell tells me the above sample value is now:
$data[0].DTSlocal
Saturday, 10 November 2012 8:09:35 AM
Ok, good. But, to find ALL the data from this date I've tried:
$data | Where-Object -Property DTSlocal -LIKE '10/11/2012*' #fails
$data | Where-Object -Property DTSlocal -LIKE '11/10/2012*' #works (!)
My Culture values are correctly set for 'Australia', viz d-MM-yyyy etc
Am I doing something wrong in having to search in 'American' format?
Update 01: Add example, as requested. Note: this is how I was trying it rather than using the subsequent suggestions. So others can learn what was going wrong. I'll also try the suggestions and report back.
Sample data file 'tinySample.json':
[
{
"DTSorig": "2012-11-09T21:09:35.612Z",
"DTSlocal": "2012-11-10T08:09:35",
"Latitude": -39.9526772,
"Longitude": 146.8924461,
"Source": "WIFI",
"Accuracy": 24
},
{
"DTSorig": "2012-11-09T21:11:32.285Z",
"DTSlocal": "2012-11-10T08:11:32",
"Latitude": -36.8526774,
"Longitude": 142.8924487,
"Source": "WIFI",
"Accuracy": 23
}
]
Powershell testing:
$data = Get-Content .\tinySample.json | ConvertFrom-Json
# quick look at PS object's values:
$data
DTSorig : 9/11/2012 9:09:35 PM
DTSlocal : 10/11/2012 8:09:35 AM
Latitude : -39.9526772
Longitude : 146.8924461
Source : WIFI
Accuracy : 24
DTSorig : 9/11/2012 9:11:32 PM
DTSlocal : 10/11/2012 8:11:32 AM
Latitude : -36.8526774
Longitude : 142.8924487
Source : WIFI
Accuracy : 23
# Find values for 10th November 2012
$data | Where-Object -Property DTSlocal -LIKE '10/11/2012*'
#nothing
$data | Where-Object -Property DTSlocal -LIKE '11/10/2012*'
# same two values returned as per $data (above)