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
hongho2
Frequent Visitor

power bi

Hi,

 

I have a date field that needs to be converted to nvarchar. In Power Query, I select the field and change the date type to text. How can I ensure that the time is not displayed from the field?

 

I also using this sytax to convert to txt field without showing time, but it didnt' work.

Text.From([#"Backlog[Order Date]"],"YYYY-MM-DD")

 

expression.jpg

1 ACCEPTED SOLUTION
v-rongtiep-msft
Community Support
Community Support

Hi @hongho2 ,

Please have a try.

One way is to use the DateTime.ToText function, which returns a textual representation of a datetime value. You can specify the format and the culture of the output as optional parameters.

= Table.TransformColumns(#“Previous Step”, {{“Date”, each DateTime.ToText(_, “MMM d yyyy”), type text}})

This will transform the column “Date” from datetime to text, using the format “MMM d yyyy”.

DateTime.ToText - PowerQuery M | Microsoft Learn

 

Another way is to use the Date.ToText function, which returns a textual representation of a date value. This function is similar to DateTime.ToText, but it only works with date values, not datetime values.

= Table.TransformColumns(#“Previous Step”, {{“Date”, each Date.ToText(_, “dd MMM yyyy”), type text}})

This will transform the column “Date” from date to text, using the format “dd MMM yyyy”.

Date.ToText - PowerQuery M | Microsoft Learn

 

A third way is to use the Text.From function, which returns a textual representation of any value.

= Table.TransformColumns(#“Previous Step”, {{“Date”, each Text.From(_), type text}})

This will transform the column “Date” from any type to text, using the default format. 

Solved: Converting specific text to date in PowerQuery - Microsoft Fabric Community

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

3 REPLIES 3
hongho2
Frequent Visitor

thank you very much !

v-rongtiep-msft
Community Support
Community Support

Hi @hongho2 ,

Please have a try.

One way is to use the DateTime.ToText function, which returns a textual representation of a datetime value. You can specify the format and the culture of the output as optional parameters.

= Table.TransformColumns(#“Previous Step”, {{“Date”, each DateTime.ToText(_, “MMM d yyyy”), type text}})

This will transform the column “Date” from datetime to text, using the format “MMM d yyyy”.

DateTime.ToText - PowerQuery M | Microsoft Learn

 

Another way is to use the Date.ToText function, which returns a textual representation of a date value. This function is similar to DateTime.ToText, but it only works with date values, not datetime values.

= Table.TransformColumns(#“Previous Step”, {{“Date”, each Date.ToText(_, “dd MMM yyyy”), type text}})

This will transform the column “Date” from date to text, using the format “dd MMM yyyy”.

Date.ToText - PowerQuery M | Microsoft Learn

 

A third way is to use the Text.From function, which returns a textual representation of any value.

= Table.TransformColumns(#“Previous Step”, {{“Date”, each Text.From(_), type text}})

This will transform the column “Date” from any type to text, using the default format. 

Solved: Converting specific text to date in PowerQuery - Microsoft Fabric Community

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Ahmedx
Super User
Super User

pls try this

 

= Date.ToText(Date.From([Order Date]))

 

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.