Hi, I’m new to this scripting language and am having trouble comparing time strings. This is what I want to do (written from my Visual Basic background):

If Time >= “7:00” and Time <= “14:59” then Shift = “1”

Trying this for FactoryPMI I got

if (DateFormat(Now(), “H:mm”) = ‘7:00’, “1”,“2”)

to work, but an error if I try

if (DateFormat(Now(), “H:mm”) > ‘7:00’, “1”,“2”)

since I’m comparing a string and not an integer.

So…I guess my question is, how do I compare a time string in an expression?

Thanks.

I figured out another way to do this:

if (dateExtract(now(), “hour”) >= 7 && dateExtract(now(), “hour”) <= 14, “1”, “0”)

Now my question is, how do I do nested, or if/else statements in FactoryPMI?

ie,

if (dateExtract(now(), “hour”) >= 7 && dateExtract(now(), “hour”) <= 14, “1”, “0”)

else if (dateExtract(now(), “hour”) >= 15 && dateExtract(now(), “hour”) <= 22, “2”, “0”)

Just to be clear, you’re talking about the expression language, not the scripting language.

To nest if statements in the expression language, you just use the second “if” as the THEN expression, like so:

```
if (dateExtract(now(), "hour") >= 7 && dateExtract(now(), "hour") <= 14,
"1",
if (dateExtract(now(), "hour") >= 15 && dateExtract(now(), "hour") <= 22,
"2",
"0")
)
```