Perspective Expression error scan illegal comma character

system.date.daysBetween(first, second) throwing an error

instead of first and second, I am using the tag paths
I am doing the expression in a label binding for the text in perspective

I don’t understand why this comma is throwing an error

I just want the difference in these two dates in minutes

A sepasoft module is producing the dates

I use the transform function usually to read them out as minutes short.

if I don’t use a transform, then 2021-4-28 8:34:31.000Z is read out

if I pick the transform minutes and short, I get like 8:24 AM

So I think my dates are coming out as good data.

Still, this comma error is concerning though, and I can’t seem to get the difference in minutes yet

system.date.daysBetween() is part of the jython scripting language. It is not a valid expression.

Are you truly using an expression, or is this a script? If it is a script, seeing the full script as well as the error would be very helpful.

If it is an expression then try the dateDiff expression function.

dateDiff(first,second,'min')

when I typed the initial post, I made an error
was using system.date.minutesBetween()

I have a label on perspective.
I click the bind for the text.
I pick expression.
I put in line 1 first= tag
line2 second = other tag
dateDiff(first,second,"min’)

error is error_configuration
Error_configuration ("Runtimeexceptions:syntax error on token:‘EQUAL’(line 1 character 6

You’re mixing scripting with the expression language.

Instead, insert the paths to the tags. and just use the expression

dateDiff({'path to first date'},{'path to second date'},'min')

ah when I use dateDiff(tag,othertag,‘min’) it works
I was mixing script stuff with expression stuff on accident

silly me

however now, it is reading like 4 decimals, and I just want the integer followed by the word minutes, aligned right if possible.

I did a transform to get the integer, but I was hoping I could also apply the “Minutes” as a string in that same label.

Oh I added an expression to the end and got it

was like {value}+" Minutes"

use toInt to convert to an integer.

concat(toStr(toInt(dateDiff({'path to first date'},{'path to second date'},'min')),'Minutes')

you’ll have to take care of the formatting with the component style.

You can find all of the expression functions here in the manual.
https://docs.inductiveautomation.com/display/DOC81/Expression+Functions

1 Like

Thanks for all your help again!

It looks great

I can’t help wondering if I am hindering myself doing it this way instead of with a tag.

I have like 30 of these to place on the page.
I think I have to make each one manually.

I’m not sure.

A single expression transform on 30 components, I wouldn’t consider a lot, but then I don’t know what else is going on in the application.

6 one way, half a dozen another. It’s really up to you to decide what works best for you, is the most understandable for the future you (or developer), and gets you the quickest most accurate results.

Thanks, you are right for sure

copy, paste the labels, replace the tag path of the dates used is the fastest

I would have to make new tags, copy folders, copy new labels the other way

I just have one lingering question for this

Did System.date.minutesBetween() fail because that is not an expression?
What is that?

I don’t understand why that fails and dateDiff() works

system.date.minutesBetween() is a scripting function.

Basically, if you ever have '.' notation you’re using scripting.

So now I am trying to make the tag invisible when over 1000 minutes.

I will have to come back to it Monday.


Monday I realized that the value was the expression without the transforms.
Was really silly to not realize on the end of that day 7 days past.

Thanks for all the help
I timed a person finding the information displayed on the page, and it was less than 2 seconds first time, only faster after.