Share via

toDate month conversion

arkiboys 9,711 Reputation points
2022-12-07T13:30:28.34+00:00

hello,
using data flow in data factory, how is it possible to get the last two digits of this column and put month.
for example:

comp_year, Quantity

-----------------------

2022 PEK01
2022 PEK02
...
2022 PEK12

Result to be:
yymm
--------
22-jan
22-feb
...
22-dec

Thank you

Azure Data Factory
Azure Data Factory

An Azure service for ingesting, preparing, and transforming data at scale.

0 comments No comments

Answer accepted by question author

MartinJaffer-MSFT 26,161 Reputation points
2022-12-08T17:49:09.457+00:00

my apologies @arkiboys . My reading must have gotten sloppy.

try like

toString(toDate(replace("2022 PEK02",' PEK','-'),'yyyy-MM'),'yy-MMM')

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. MartinJaffer-MSFT 26,161 Reputation points
    2022-12-07T20:10:39.967+00:00

    Hello @arkiboys ,
    Thanks for the question and using MS Q&A platform.

    As I understand, you would like a pipeline expression to convert "2022 PEK02" to "22-feb".

    @formatDateTime(  
        replace(pipeline().parameters.testdata, ' PEK', '-')  
        ,'yy-MMM')  
    

    formatDateTime expects a form somewhat datelike. To turn "2022 PEK-2" into "2022-02" I replace the " PEK" with "-".
    Then I use the format string "yy-MMM" to specify 2 digits for the year, and 3 "M" mean 3 letters for month. 2 "M" would give a number.

    Please do let me if you have any queries.

    Thanks
    Martin


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
      • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.