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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
David283
Helper I
Helper I

Problem converting dates from text, mixed formats in one column.

I have a table with a mix of date formats in one column.  Some are in the excel serial number format, and others are in a date/time/timezone format.  please see image below.

 

David283_0-1660938273151.png

 

 

I need to convert these into date only format.  I know how to use transfom and get the date only from the date/time/timezone ones, but I somehow need to fix the serial number ones first.  How can I go about this?

1 ACCEPTED SOLUTION
edhans
Community Champion
Community Champion

I would fix them in a few steps. You can do this 99% with the user interface and simple and easy to follow formulas.

  1. Create a new column with the following formula: if Text.Length([DateField]) = 5 then Number.FromText([DateField]) else null - this will return an integer.
  2. Now convert that to a date.
  3. Now another new column - if Text.End([DateField], 1) = "Z" then [DateField] else null - this will pull your time fields.
  4. Convert that to datetime.
  5. Now you have to get them to be both the same, either both date, datetime, or datetimezone. Convert them to the same, then one last column:
    1. if [FirstDate] = null then [SecondDate] else [FirstDate]
  6. Delete the temp first and second date, and the original date field.


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
Community Champion
Community Champion

I would fix them in a few steps. You can do this 99% with the user interface and simple and easy to follow formulas.

  1. Create a new column with the following formula: if Text.Length([DateField]) = 5 then Number.FromText([DateField]) else null - this will return an integer.
  2. Now convert that to a date.
  3. Now another new column - if Text.End([DateField], 1) = "Z" then [DateField] else null - this will pull your time fields.
  4. Convert that to datetime.
  5. Now you have to get them to be both the same, either both date, datetime, or datetimezone. Convert them to the same, then one last column:
    1. if [FirstDate] = null then [SecondDate] else [FirstDate]
  6. Delete the temp first and second date, and the original date field.


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

You had me all the way till step 6 🙂

 

I did steps 1 - 5 and it worked great, thank you! 

 

But step 6...  This is a power BI report and more data will roll in every day.  I plan to try to figure out and fix my source, but in the mean time, do I need to leave the conversion formulas and columns in place so that these automaticly convert each day?

edhans
Community Champion
Community Champion

No. Tomorrow when new data comes in, it will rerun all of these steps. It is just deleting those columns before it gets loaded to Power BI. Look at the steps that are being created on the right side of the Power Query window. Think of that as a macro. It isn't like Excel where it is permenantly deleting those columns. It only deletes the columns after steps 1-5 are done again.



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

Understood.

 

Marking solution, Thanks for the help!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.