microsoft / Intune-Data-Warehouse

Libraries, samples, and feedback on the Intune Data Warehouse.
MIT License
33 stars 18 forks source link

DataFormat #7

Closed ibrahimsharif closed 6 years ago

ibrahimsharif commented 6 years ago

Recived Data From Device collection, Data Format are not Formatet correctly

This Lines are from the Powershell Module

"startDateInclusiveUTC":  "2017-10-16T00:00:00Z",
"endDateExclusiveUTC":  "9999-12-31T00:00:00Z",
"isCurrent":  true,
"rowLastModifiedDateTimeUTC":  "2017-10-17T00:24:11.8233333Z",

this is how the date shold appear

image

Sorry my Broken Englsih 🔢 :)

nickciaravella commented 6 years ago

Hey Ibrahim,

Dates and times that are returned from the API are represented as strings, since JSON has no DateTime type. In PowerShell, you can convert these to any format by first parsing the string into a DateTime object, then converting it back to a string with your preferred format specifier. Here is an example to get the string into the format that Power BI Is displaying in your screenshot above.

$dateTime = [datetime]::parse("2017-10-16T00:00:00Z")
$dateTime.ToString("g")
10/15/2017 5:00 PM

Here are more details on the possible format specifiers: Standard: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings Custom: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

Let me know if this solves your issue!

ibrahimsharif commented 6 years ago

Nice Thanks, i did as below and it works jubii [datetime]::parse("2017-10-16T00:00:00Z").Tostring('MM/dd/yy HH:mm:ss')

have a greate day, your are my hero today

nickciaravella commented 6 years ago

Excellent! Glad it worked for you.