Integration

Get Involved. Join the Conversation.

Topic

    Ritu
    DateTime Issues : DD-MON-RRRRAnswered
    Topic posted November 15, 2019 by RituSilver Medal: 2,000+ Points, tagged Integration, Mapping 
    21 Views, 1 Comment
    Title:
    DateTime Issues : DD-MON-RRRR
    Content:

    Hi All,

    My requirement is to format the input date and subtract one day from the given date. The requirement sounds simple but the date is not getting formatted.

    Input Date : DD-MON-RRRR e.g. 01-JAN-2019

    string(xp20:format-dateTime($InputDate,'[DD]-[MM]-[YYYY]') - xsd:dayTimeDuration('P1D')) -  not working

    string(xp20:format-dateTime($InputDate,'[DD]-[MN,*-3]-[YYYY]') - xsd:dayTimeDuration('P1D')) -  not working

    string(xp20:format-dateTime($InputDate,'[D01]-[MN,*-3]-[Y0001]') - xsd:dayTimeDuration('P1D')) -  not working

    Thanks,

    Ritu

    Best Comment

    Hemanth Lakkaraju

    All expressions are incorrect. format-dateTime expects ISO Date Format. Try below and see if it works!

    Input String --> 01-JAN-2019

    Approach:
    1. Use Look up to convert month names to numbers.
    2. Convert Input String to ISODate Format.
        a. d = substring-before($Input,'-')
        b. m = substring-before(substring-after($Input,'-'),'-')
        c. y = substring-after(substring-after($Input,'-'),'-')
        d. mn = Use lookup(pass m and get number value)
        e. isoDate = concat($y,'-',$mn,'-',$d,'T00:00:00') (--> You can add Time or Zone if required, default UTC 00:00:00)
    3. Subtract 1 Day now.
        a. newDate = xsd:dateTime($iso)-xsd:dayTimeDuration('P1D')
    4. Convert back to Input String format
        a. xp20:format-dateTime($newDate, '[D01]-[MN,*-3]-[Y0001])

    Comment

     

    • Hemanth Lakkaraju

      All expressions are incorrect. format-dateTime expects ISO Date Format. Try below and see if it works!

      Input String --> 01-JAN-2019

      Approach:
      1. Use Look up to convert month names to numbers.
      2. Convert Input String to ISODate Format.
          a. d = substring-before($Input,'-')
          b. m = substring-before(substring-after($Input,'-'),'-')
          c. y = substring-after(substring-after($Input,'-'),'-')
          d. mn = Use lookup(pass m and get number value)
          e. isoDate = concat($y,'-',$mn,'-',$d,'T00:00:00') (--> You can add Time or Zone if required, default UTC 00:00:00)
      3. Subtract 1 Day now.
          a. newDate = xsd:dateTime($iso)-xsd:dayTimeDuration('P1D')
      4. Convert back to Input String format
          a. xp20:format-dateTime($newDate, '[D01]-[MN,*-3]-[Y0001])