Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Transform text column to Date

Hi, I power Query I have a text column YearMonth and I want to convert this to a date column. I can do this by creating a custom column but how can I do this by Transforming the column as I don't ...
  • ronrsnfld's avatar
    2 years ago

    Try

        #"Transform to Dates" = Table.TransformColumns(#"Previous Step", {
            {"yearMonth", each 
                let 
                    parts = Splitter.SplitTextByLengths({4,2})(_),
                    partsN = List.Transform(parts, each Number.From(_))
                in 
                    #date(partsN{0},partsN{1},1),
                    type date
                    }})