sandy666
02-20-2021, 10:29 AM
(question from the web (https://www.mrexcel.com/board/threads/transforming-text-to-date-in-power-query.1162407/))
I ma trying to transfomr an 8 digit text to a Date in Power Query. For instance, I want to transform in Power Query 02012021 to 02/01/2021 and format it
as a date?
TextTextDate
0201202102012021
02/01/2021
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Date = Table.AddColumn(Source, "Date", each
Date.FromText
(
Text.Format("#[day]/#[month]/#[year]",
[
day = Text.Start([Text],2),
month = Text.Middle([Text],2,2),
year = Text.End([Text],4)
],
"en-GB")
)
),
Type = Table.TransformColumnTypes(Date,{{"Date", type date}})
in
Type
I ma trying to transfomr an 8 digit text to a Date in Power Query. For instance, I want to transform in Power Query 02012021 to 02/01/2021 and format it
as a date?
TextTextDate
0201202102012021
02/01/2021
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Date = Table.AddColumn(Source, "Date", each
Date.FromText
(
Text.Format("#[day]/#[month]/#[year]",
[
day = Text.Start([Text],2),
month = Text.Middle([Text],2,2),
year = Text.End([Text],4)
],
"en-GB")
)
),
Type = Table.TransformColumnTypes(Date,{{"Date", type date}})
in
Type