Using results from regexp_substr in a date formula...
# suitescript
r
Using results from regexp_substr in a date formula After lots'a trial and error its time to ask for some help! Our item names contain a "value" that I need to extract and add to a date field. For example, the item name is ABC-2YR. I need to create a formula that extracts the "2" and adds it the year of a date field. So if the Year of the {expiration_date} field is 2020, my calculated column results in 2022. a) To extract the value from the item field, I've used: regexp_substr ({item},'.+-(.)',1,1,null,1). This returns the correct "value" needed from the field. b) To extract the year from the expiration date field, I've used: Extract (Year From {expiration_date}). This returns the year (4 digit) from the field. How do I add the two together? This part I can't figure out and keep getting an error. Thanks for any suggestions.
b
my personal advice is to do it in script
your formula is approaching the point of absurd
that said, my half response will be that you dont do addition with strings
r
Appreciate the reply. I was able to solve this by simply wrapping TO_NUMBER around the regexp_substr as in: TO_NUMBER(regexp_substr ({item},'.+-(.)',1,1,null,1)) I was then able to use the results in formulas without error!