Delimit the string from the text column in adf data flow

Venkatesh Srinivasan 86 Reputation points
2021-12-14T14:15:53.553+00:00

Hi All,

Please help me out here! I'm trying to delimit the string to extract the date from the text column

Here is my value = "x-x-x-2021-12-13.json" trying to get only date value from the text.

Note: Need data flow expression because i'm doing this in data flow adf

Please help me out with the adf expression

Thanks in advance!

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,624 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 60,161 Reputation points
    2021-12-14T15:38:41.657+00:00

    Is that a time that is at the start of the filename and you want to strip it off or is it something else? To convert a string to a date then you can use the toDate function in an expression.

       toDate(filename)  
    

    Note that there is no just date type so all your values are going to include a time. If you need to filter out time for display/comparison/etc purposes then you can do that at the point you need to exclude them.

       toString(myDate, 'yyyy-MM-dd')  
    

    If the filename has other stuff in front then you might first need to use regexExtract to capture just the date portion and then use toDate to convert it to a datetime value.

       toDate(regexExtract(filename, '[0-9]{4}-[0-9]{2}-[0-9]{2}\.json$'), 'yyyy-MM-dd')  
    

    Just guessing a little on the RE. [0-9] matches a digit. {4} says there should be 4. $ says end of string. If your dates use single and double digit months/days then the expression needs to adjust a little.

    1 person found this answer helpful.
    0 comments No comments

  2. ShaikMaheer-MSFT 38,546 Reputation points Microsoft Employee Moderator
    2021-12-15T16:52:39.38+00:00

    Hi @Venkatesh Srinivasan ,

    Thank you for posting query in Microsoft Q&A Platform.

    You can use below expression data flows. Kindly check.
    toDate(split(replace(myValue,'x-x-x-',''),'.')[0],'yyyy-MM-dd')

    Hope this will help. Please let us know if any further queries.

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

    Please consider hitting Accept Answer button. Accepted answers helps community as well.


Your answer

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