locked
SQL Server changing the date formate RRS feed

  • Question

  • Hi,

    I have the date for mate like  

    January, 2016

    January, 2017

    January, 2018

    February,2016

    February,2017

    February,2018

    .

    .

    .

    I want to convert them into

    01/2015

    01/2016

    02/2017

    .

    .

    I have huge records. can I convert column in SQL table using Excel . I did some thing like below in excel, what is the next step? 

    April, 2015 04/2015
    April, 2016 04/2016
    April, 2017 04/2017
    April, 2018 04/2018
    August, 2014 08/2014
    August, 2015 08/2015
    August, 2016 08/2016
    August, 2017 08/2017
    December, 2014 12/2014

    thanks,

    RR


    Raja

    Tuesday, February 27, 2018 6:16 AM

Answers

  • Hi Raja,

    Thanks for your question.

    In this scenario, please try to use DAX switch function to get the desired results in EXCEL Power Pivot.

    Please create a calculated column as below DAX formula:
    Deisreformat =
    SWITCH (
        LEFT ( Table2[Date], FIND ( ",", Table2[Date],, -1 ) - 1 ),
        "January", "01/" & RIGHT ( Table2[Date], 4 ),
        "February", "02/" & RIGHT ( Table2[Date], 4 ),
        "March", "03/" & RIGHT ( Table2[Date], 4 ),
        "April", "04/" & RIGHT ( Table2[Date], 4 ),
        "May", "05/" & RIGHT ( Table2[Date], 4 ),
        "June", "06/" & RIGHT ( Table2[Date], 4 ),
        "July", "07/" & RIGHT ( Table2[Date], 4 ),
        "August", "08/" & RIGHT ( Table2[Date], 4 ),
        "September", "09/" & RIGHT ( Table2[Date], 4 ),
        "October", "10/" & RIGHT ( Table2[Date], 4 ),
        "November", "11/" & RIGHT ( Table2[Date], 4 ),
        "December", "12/" & RIGHT ( Table2[Date], 4 ),
        "Unknown"
    )
    


    Best Regards
    Willson Yuan
    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, February 28, 2018 2:33 AM