Forum Discussion

godtooro's avatar
godtooro
Helper II
3 years ago
Solved

Column DATE from column (20310312)

Dear all,   I've a column in this format: 20210312 (YYYYMMDD). I want to create a new colum date. How can I do it? Because with date(column) it doesn´t works.
  • Samarth_18's avatar
    3 years ago

    Hi godtooro ,

     

    You could try below code:-

    new_date = 
    VAR _year =
        MID ( 'Table'[Column1], 1, 4 )
    VAR _month =
        MID ( 'Table'[Column1], 5, 2 )
    VAR _day =
        MID ( 'Table'[Column1], 7, 2 )
    RETURN
     DATEVALUE ( _year & "-" & _month & "-" & _day )

    Output:-

     

    Thanks,

    Samarth