Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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?

2 ACCEPTED SOLUTIONS
jennratten
Super User
Super User

Hello - this should do it...

Table.AddColumn(entity, "Custom", each Date.ToText(Date.From(DateTime.FixedLocalNow()), "ddd MMM d yyyy"), type date)

jennratten_1-1649926401881.png

 

View solution in original post

Anonymous
Not 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)

 

View solution in original post

5 REPLIES 5
jennratten
Super User
Super User

Hello - this should do it...

Table.AddColumn(entity, "Custom", each Date.ToText(Date.From(DateTime.FixedLocalNow()), "ddd MMM d yyyy"), type date)

jennratten_1-1649926401881.png

 

Anonymous
Not 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:

ianmacleod_0-1649936662929.png

 

Anonymous
Not 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)

 

Anonymous
Not applicable

Perfect.  Thank you so much 😊

Great!  You're welcome!  Please accept the solution when you have a moment. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors