Skip to content

Arithmetics with instr is buggy #134

@romaintailhurat

Description

@romaintailhurat

I'm trying to implement a simple feat with a duration string, that is extracting the month value for:

P100Y11M

We don't have yet a duration type implemented in Trevas JS, i'm trying to simply parse the string*.

One way to do it is to use substr and instr (here DD is a string with value P100Y11M):

substr(
    DD, 
    instr(DD, "Y") + 1, 
    (instr(DD, "M")-instr(DD, "Y"))-1
)

But i'm getting the following error:

Type errors: Error: extraneous input '-1' expecting ')'

If i try the same formula using a scalar as the length param, it works:

substr(
    DD, 
    instr(DD, "Y") + 1, 
    2
)

It's probably not a problem with substr, because this is also raising the same error as previously:

instr(DD, "M")-(instr(DD, "Y")-1)

@NicoLaval we can discuss that and even pair programming over this when you find time 😃

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions