Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Replacing a Datekey in integer format with todays date as integer

Hi,

 

I have a table with a datekey column as an integer on the form yyyymmdd. I want to replace the values 10010101 to today's date in power query. So today I will want to replace 10010101 to 20230609. Is there any way I can do this?

  • Hi,

    add Number.FromText

     Table.ReplaceValue(Previous_Step,10010101,Number.FromText(DateTime.ToText(DateTime.LocalNow(),"yyyyMMdd")),Replacer.ReplaceValue,{"Date"})

    Stéphane 

3 Replies

  • Hi,

     

    = Table.ReplaceValue(Previous_Step,10010101,DateTime.ToText(DateTime.LocalNow(),"yyyyMMdd"),Replacer.ReplaceValue,{"Date"})

    Stéphane 

    • Anonymous's avatar
      Anonymous
      Not applicable

      I see that this solution returns the value as text, is it possible to change it to integer?

  • Hi,

    add Number.FromText

     Table.ReplaceValue(Previous_Step,10010101,Number.FromText(DateTime.ToText(DateTime.LocalNow(),"yyyyMMdd")),Replacer.ReplaceValue,{"Date"})

    Stéphane