Application Studio - Add/Subtract from Datetime variable

This is in Kinetic - Application Studio.

I’m trying to get the past year’s worth of rows by subtracting a year from a datetime variable, but I don’t know the correct way of writing that expression.

Looking at how Constant.Today is formated (2025-01-08T00:00:00.000), I want to subtract a year from it (0001-00-00T00:00:00.000).

image

What kind of coding language does the Expression field use? JavaScript? C#?

In the base events I see methods can be used in this Expression field for strings, i.e:
“expression”: “‘{sysPages.epBinding}’.startsWith(‘LandingPage’)
“expression”: “‘{Part.PartDescription}’.substring(0, 8)
“expression”: “‘%value%’ == ‘CHARACTER’ && ‘{PartPlant.SNPrefix}’.length > 10”

I suppose it would also make sense to me if you can use methods for datetime variables:
image

or something like that

JavaScript.

3 Likes

Idk why but I thought that that was for the custom function you guys were talking about in that post.
This works just fine in the expression field, thanks!

Edit: I did have to change your function from .toLocaleDateString() to .toISOString() so that the format is the same as the PartTran.TranDate’s format. Which the comparison needs to work.

#‘(new Date(new Date().getFullYear() - 1, new Date().getMonth(), new Date().getDate())).toISOString()’#

Also, you can use that in row-update’s expression field to set a variable as the modified date:
image

1 Like