Forum Discussion
Date Type with Day
Hello
Does anyone know if it is possible to use M code in PQE to create a date type column in the following format:
Thu Apr 14 2022
Please?
Hello - this should do it...
Table.AddColumn(entity, "Custom", each Date.ToText(Date.From(DateTime.FixedLocalNow()), "ddd MMM d yyyy"), type date)- Anonymous4 years ago
This works for transforming an existing column:
Select: Add Column, Column From Examples, From Selection > with the current date column selected, then:
= Table.AddColumn(#"Duplicated Column1", "Custom", each Text.Combine({Date.ToText([Date Raised], "ddd"), " ", Date.ToText([Date Raised], "%d"), " ", Date.ToText([Date Raised], "MMM"), " ", Date.ToText([Date Raised], "yyyy")}), type text)
5 Replies
- jennrattenSuper User
Hello - this should do it...
Table.AddColumn(entity, "Custom", each Date.ToText(Date.From(DateTime.FixedLocalNow()), "ddd MMM d yyyy"), type date)- AnonymousNot applicable
Perfect. Thank you so much 😊
- jennrattenSuper User
Great! You're welcome! Please accept the solution when you have a moment.
- AnonymousNot applicable
Hi Jen
It does work, But.
I should have said that need to change the format for an existing column.
I have tried duplicating the column then incorporate the M code that you said, but, I must be doing something wrong.
= Table.TransformColumns(#"Duplicated Column1","Current Due Date DAY", each Date.ToText(Date.From(DateTime.FixedLocalNow()), "ddd d MMM yyyy"), type date)
I receive the following error:
- AnonymousNot applicable
This works for transforming an existing column:
Select: Add Column, Column From Examples, From Selection > with the current date column selected, then:
= Table.AddColumn(#"Duplicated Column1", "Custom", each Text.Combine({Date.ToText([Date Raised], "ddd"), " ", Date.ToText([Date Raised], "%d"), " ", Date.ToText([Date Raised], "MMM"), " ", Date.ToText([Date Raised], "yyyy")}), type text)