Discussions

 View Only
  • 1.  Strings and Integers in a Pipeline Date Calculations

    Posted 01-05-2023 21:55
    I am trying to formulaically change a date with a Pipeline

    If I hard code the change in the date it will work with the following expression

    {{a.date +time.delta(days=2)}}

    However if I use a variable 

    {{a.date +time.delta(days='a.numeric_field')}}

    I get the error

    Validation error: Incorrect template "{{a.date +time.delta(days='a.numeric_field')}}". TypeError: cannot concatenate 'str' and 'int' objects 

    The field a.date is the string and a.numeric_field is my integer

    I have tried all sort of variations to convert the data type such as 
    'a.numeric_field|str'
    Str(a.numeric_field)

    However my syntax is aways wrong.

    Any suggestions would be greatly appreciated.

    ------------------------------
    Don Larson
    ------------------------------


  • 2.  RE: Strings and Integers in a Pipeline Date Calculations
    Best Answer

    Posted 01-06-2023 09:02
    Hi Don, you need to specify the field without the quotes:

    {{a.date +time.delta(days=a.numeric_field)}}

    If a.date is a string and not a date, then you need to parse it:

    {{time.parse(a.date) +time.delta(days=a.numeric_field)}}

    Hope that helps!

    ------------------------------
    Doug Henning
    ------------------------------