Forum Discussion

David283's avatar
David283
Helper I
4 years ago
Solved

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.       I need to...
  • edhans's avatar
    4 years ago

    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.