question

LumiOueb-1440 avatar image
0 Votes"
LumiOueb-1440 asked Lz-3068 commented

Expression.Error: We cannot convert the value to type Date.


I have a problem with a column that cannot be used as date : 70598-image.png

My value seems to be in date format ( I tried to change it from date to datetime, the time is added)
70605-image.png

but when I try to change it, it's not recognised as date and I get the error

 let
     Source = Excel.CurrentWorkbook(){[Name="GETTNINFO"]}[Content],
     #"Changed Type" = Table.TransformColumnTypes(Source,{
                 {"Source.Name1", type text}, {"Seq No.", Int64.Type}, {"Doc No.", type text}, {"Doc Rev", type text}, {"Issue Purpose", type text}, {"Title", type text}, {"Sent Date", type date}}),
      
     #"Inserted Parsed Date" = Table.AddColumn(#"Changed Type", "Rev. Date", each Date.ToText("Sent Date","MM/dd/yyyy")),


I don't understand exactly the issue I'm afraid. I tried to set the column as date, not datetime . It seems to change the date ( the time disappear) but the error is still the same



power-query-not-supported
image.png (9.7 KiB)
image.png (11.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Lz-3068 avatar image
1 Vote"
Lz-3068 answered

Hi @LumiOueb-1440

If you get the error on the #"Inserted Parsed Date" step, change it with:

 #"Inserted Parsed Date" = Table.AddColumn(#"Changed Type", "Rev. Date", each
     Date.ToText([Sent Date],"MM/dd/yyyy"), type text
 )

As you reference a column name/field you must pass it to the function (Date.ToText in the case) between [], not between "" (double quotes) as you did

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LumiOueb-1440 avatar image
0 Votes"
LumiOueb-1440 answered Lz-3068 commented

Thanks a lot, I'm still a little fuzzy when I should use "" and when it's [] and I really didn't understand the error as I was more checking the type or if I didn't made an error wording "DateTime / datetime" or other.

Thanks a lot !

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Glad I could help @LumiOueb-1440 & Thanks for posting back

0 Votes 0 ·