I have the following problem. I have a column called "StartDate". The column is a string, like "15.01.2025 07:28".
I wanted to convert this into a date. So I used this syntax:
= Table.TransformColumns(Source,
{"StartDate", each Date.FromText(Text.Range(_, 0, 10), [Format="dd.MM.yyyy"]), type date})
(as described here: )
But it didn’t work. I got the error message:
Expression.Error: We cannot convert a value of type Record to type Text.
Details:
Value=
Format=dd.MM.yyyy
Type=[Type]
After some try and error I found out, that this works:
= Table.TransformColumns(Source,
{"StartDate", each Date.FromText(Text.Range(_, 0, 10), "de-DE"), type date})
But I don’t understand this. The manual clearly states there should be a record here not a string. Also this string only accepts Cultures, not format strings.
Why doesn’t it work currectly in Excel? And how could I use format string here?
I use Excel 2019 btw.
I have the following problem. I have a column called "StartDate". The column is a string, like "15.01.2025 07:28".
I wanted to convert this into a date. So I used this syntax:
= Table.TransformColumns(Source,
{"StartDate", each Date.FromText(Text.Range(_, 0, 10), [Format="dd.MM.yyyy"]), type date})
(as described here: https://learn.microsoft/en-us/powerquery-m/date-fromtext#example-4)
But it didn’t work. I got the error message:
Expression.Error: We cannot convert a value of type Record to type Text.
Details:
Value=
Format=dd.MM.yyyy
Type=[Type]
After some try and error I found out, that this works:
= Table.TransformColumns(Source,
{"StartDate", each Date.FromText(Text.Range(_, 0, 10), "de-DE"), type date})
But I don’t understand this. The manual clearly states there should be a record here not a string. Also this string only accepts Cultures, not format strings.
Why doesn’t it work currectly in Excel? And how could I use format string here?
I use Excel 2019 btw.
Share Improve this question edited Jan 30 at 15:53 davidebacci 30.3k4 gold badges18 silver badges47 bronze badges asked Jan 30 at 15:42 Martini BiancoMartini Bianco 1,8251 gold badge19 silver badges28 bronze badges 4 |1 Answer
Reset to default 1It is probably your older version of Excel. In Excel 365, your first code works perfectly.
yMd
? Also, the article you cite indicates that options can also be a text string "to support legacy workflows". But if you use a text string, you can only specify the culture, not the format. Your code does work as expected for me, too, using365
. – Ron Rosenfeld Commented Jan 30 at 21:47Table.TransformColumns(Source, {"StartDate", each Date.FromText(Text.Range(_, 0, 10), [Culture="de-DE"]), type date})
. If that doesn't work, then probably your version of that PQ function does not support theoptions
record. If it does work, then possibly your year-month-day tokens are different than what you are using. – Ron Rosenfeld Commented Jan 31 at 0:41[Culture="de-DE"]
doesn't work, the logical conclusion is that the version of PQ packaged with2019
does not include theOptions
record but rather is considered alegacy workflow
. I do not believe you can use the format string with this function unless you upgrade your Excel or switch to Power BI. – Ron Rosenfeld Commented Jan 31 at 12:10