Forum Discussion

DonLarson's avatar
DonLarson
Qrew Commander
2 years ago

Strings and Integers in a Pipeline Date Calculations

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
------------------------------
  • 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
    ------------------------------
  • DougHenning1's avatar
    DougHenning1
    Community Manager
    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
    ------------------------------