Forum Discussion
Convert Excel Serial Date to normal m/d/yyyy hh:mm
- 6 years ago
Hi lardo5150 ,
You can try steps like below:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("NcjBCcAwDAPAXfwuxqlkOZ4leP81AoXe884xoiRXbJAdRZvny4Rnc6Na+I/lfHMFl1Q2cwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [date = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type number}}), #"Split Column by Character Transition" = Table.SplitColumn(Table.TransformColumnTypes(#"Changed Type", {{"date", type text}}, "en-US"), "date", Splitter.SplitTextByCharacterTransition({"0".."9"}, (c) => not List.Contains({"0".."9"}, c)), {"date.1", "date.2"}), #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Character Transition",{{"date.1", Int64.Type}, {"date.2", type number}}), #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each Date.AddDays(#date(1900, 01, 01), [date.1])), #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Time.From([date.2])), #"Changed Type2" = Table.TransformColumnTypes(#"Added Custom1",{{"Custom", type date}, {"Custom.1", type time}}), #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Changed Type2", {{"Custom", type text}, {"Custom.1", type text}}, "en-US"),{"Custom", "Custom.1"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged"), #"Changed Type3" = Table.TransformColumnTypes(#"Merged Columns",{{"Merged", type datetime}}) in #"Changed Type3"Here is the sample pbix.
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ok, so I SPLIT the ClosedDateTime column by using the deliminator of (.)
That created ClosedDateTime.1 and ClosedDateTime.2
I used this for ClosedDateTime.1
Date.AddDays(#date(1900, 01, 01), [ClosedDateTime.1])
This gave me the date, which is great.
But I can't get the time in ClosedDateTime.2. Do you know what the correct expression is?
Hi lardo5150 ,
You can try steps like below:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("NcjBCcAwDAPAXfwuxqlkOZ4leP81AoXe884xoiRXbJAdRZvny4Rnc6Na+I/lfHMFl1Q2cwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type number}}),
#"Split Column by Character Transition" = Table.SplitColumn(Table.TransformColumnTypes(#"Changed Type", {{"date", type text}}, "en-US"), "date", Splitter.SplitTextByCharacterTransition({"0".."9"}, (c) => not List.Contains({"0".."9"}, c)), {"date.1", "date.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Character Transition",{{"date.1", Int64.Type}, {"date.2", type number}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each Date.AddDays(#date(1900, 01, 01), [date.1])),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Time.From([date.2])),
#"Changed Type2" = Table.TransformColumnTypes(#"Added Custom1",{{"Custom", type date}, {"Custom.1", type time}}),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Changed Type2", {{"Custom", type text}, {"Custom.1", type text}}, "en-US"),{"Custom", "Custom.1"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged"),
#"Changed Type3" = Table.TransformColumnTypes(#"Merged Columns",{{"Merged", type datetime}})
in
#"Changed Type3"Here is the sample pbix.
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- lardo51506 years ago
Microsoft Employee
EXACTLY what I was looking for and I was able to follow what you were doing.
Providing the sample was a BIG help.
THANK YOU