Forum Discussion
[M language] Transform column type to datetime with 2 string formats?
- 8 years ago
You shouldn't replace the "_" at all.
My intenton was to have you just follow the indicated steps and only adjust the generated code by adding the if .. then .. else part,
But if you want to copy and adjust the code, then change the previous step name and the column reference.
According to your example code, this would be:
#"Convert Date" = Table.TransformColumns(#"Expanded Document",{{"Document.timestamp", each Date.From(DateTimeZone.From(_, if Text.Contains(_,"M") then "en-US" else "nl-NL")), type date}})
Select the column, choose transform tab - Date - Parse and adjust the generated code to determine the culture (the if .. then ..else in the code below):
= Table.TransformColumns(Source,{{"Document.Timestamp", each Date.From(DateTimeZone.From(_, if Text.Contains(_,"M") then "en-US" else "nl-NL")), type date}})
- loic_bouscaud8 years agoRegular Visitor
Thanks MarcelBeug for your answer.
I tried your to use your code and replaced the "_" by my timestamp column but I still got the same error.
What should I use to replace the "_"?
- MarcelBeug8 years ago
Community Champion
You shouldn't replace the "_" at all.
My intenton was to have you just follow the indicated steps and only adjust the generated code by adding the if .. then .. else part,
But if you want to copy and adjust the code, then change the previous step name and the column reference.
According to your example code, this would be:
#"Convert Date" = Table.TransformColumns(#"Expanded Document",{{"Document.timestamp", each Date.From(DateTimeZone.From(_, if Text.Contains(_,"M") then "en-US" else "nl-NL")), type date}})- loic_bouscaud8 years agoRegular Visitor
Thanks a lot for your help, it's working now.
But what does the '_' mean in the formula?
I think it's the solution I was looking for. If I compare the code you send me and the code I made first, there are similar.