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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
rmocca
Helper I
Helper I

Add a new datetime column from string

Hi,

I have a simple question:

I have a table with a column called Value, which is a string type. Some rows have a string DateTime, such as yyyy/MM/dd, but others have numbers or even alphanumeric codes.

I need to get a new column, converting the DateTimes and setting nulls for the rest of the rows.

 

It's that possible?

 

I appreciate your help.

 

Thanks,

Rodrigo Mocca

1 ACCEPTED SOLUTION
edhans
Super User
Super User

Yes. Power Query is the best place to do this. Often the Date.FromText() function can handle a number of text formats.

  • December 31, 2020
  • 20201231
  • 2020-12-31

Those are a few. If you add a new column in Power Query and use this, you will either get a date or a null.

= try Date.FromText([Your Text Date Field]) otherwise null

If you can post some sample data, we can help with formats that Power Query does't natively recognize.

 

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

4 REPLIES 4
edhans
Super User
Super User

Yes. Power Query is the best place to do this. Often the Date.FromText() function can handle a number of text formats.

  • December 31, 2020
  • 20201231
  • 2020-12-31

Those are a few. If you add a new column in Power Query and use this, you will either get a date or a null.

= try Date.FromText([Your Text Date Field]) otherwise null

If you can post some sample data, we can help with formats that Power Query does't natively recognize.

 

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Hi,

Thanks for your help. I'll try this now.

 

Thanks again

amitchandak
Super User
Super User

@rmocca , check for alphanumerics

https://community.powerbi.com/t5/Desktop/Checking-a-column-for-alpha-and-alpha-numeric-characters/td...

 

use test function to get date

https://docs.microsoft.com/en-us/powerquery-m/text-functions

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for the information.

I'll take a look ASAP.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Users online (2,553)