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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Giripavan
Employee
Employee

DateTime Conversion

Hello All,

 

I am getting data from an API using powerquery. Result is a JSON file which we are expanding into columns. One of the column is CreateDate which is of format "yyyy-MM-DDTHH:MM:SS.ms"

Ex: 2021-06-29T00:52:19.343

This column is being considered as Text in the report, when I am trying to convert it to datetime, it is not able to convert it automatically and giving error as "We can't automatically convert the column to Date/Time type".

Is there any way to convert this column to date time?

 

Thanks,

Giripavan.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Giripavan , try if you can use DateTime.FromText in new column.

 

This should take this time as per example in

https://docs.microsoft.com/en-us/powerquery-m/datetime-fromtext

 

else replace T using Text.Replace

 

example 

DateTime.FromText (Text.Replace([DT], "T", " "))

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Giripavan , try if you can use DateTime.FromText in new column.

 

This should take this time as per example in

https://docs.microsoft.com/en-us/powerquery-m/datetime-fromtext

 

else replace T using Text.Replace

 

example 

DateTime.FromText (Text.Replace([DT], "T", " "))

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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