Forum Discussion

admin_xlsior's avatar
admin_xlsior
Post Prodigy
7 years ago
Solved

change date format

Hi guys,   I have a Direct Query table from SQL Server which I have a column Datekey (type : Date/Time) -> 1/1/2019 12:00:00 AM   How to have a new column, same with that but with format "YYYYMM"...
  • v-juanli-msft's avatar
    7 years ago

    Hi admin_xlsior 

    In Edit queries,

    1.click on your column Datekey, then select Add column->Date->Date only, thus get a column named "Date.1"

    2.click on column "Date.1", then select Add column->Date->Year, thus get a column named "Year"

    3.click on column "Date.1", then select Add column->Date->Month, thus get a column named "Month"

    4.click on column "Month", then select Add column->Extract->length, thus get a column named "Length"

    5.add a conditional column

    6.select two columns and merge them,

    click on "Custom" first, then keep the "ctrl" button pressed, click on another column "Month",

    then select Add column->merge.

    Then i get a new column "Merged"

     

    7.finally, merge two columns "Year" and "Merged", you could remove other columns but keep useful columns.

     

    Best Regards

    Maggie

     

    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.