Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Convert number (text) to date

Hi,

 

I'm trying to convert a number from YYYYMMD (missing the complete day input) to showing YYYYMM. I guess this should be simple, but i dont manage to do it. Please help.

 

I was trying to extract the first 6 values and then change to date format, but did not succeed...

 

BR Patrik

  • Use following in a custom column where Date is the column which this field

    = Date.FromText(Text.Start(Text.From([Date]),6),[Format="yyyyMM"])

    If you don't want to use custom column but want in place replacement, then insert this statement where #"Changed Type" should be replaced by your previous step

    = Table.ReplaceValue(#"Changed Type",each [Date],each Date.FromText(Text.Start(Text.From([Date]),6),[Format="yyyyMM"]),Replacer.ReplaceValue,{"Date"})

     

1 Reply

  • Vijay_A_Verma's avatar
    Vijay_A_Verma
    Most Valuable Professional

    Use following in a custom column where Date is the column which this field

    = Date.FromText(Text.Start(Text.From([Date]),6),[Format="yyyyMM"])

    If you don't want to use custom column but want in place replacement, then insert this statement where #"Changed Type" should be replaced by your previous step

    = Table.ReplaceValue(#"Changed Type",each [Date],each Date.FromText(Text.Start(Text.From([Date]),6),[Format="yyyyMM"]),Replacer.ReplaceValue,{"Date"})