Manipulating sunset for duration

I am stuck. I am trying to get my lights to turn on at a certain time (sunset - 30) and then fade from 100% to 20% and hit 20% at 9pm. I’ve tried different expressions for the duration, but keep coming up with high numbers. For instance:

{datetime(‘9PM’)} - {$sunset}

Gives me a large negative number (-32275537). Can someone give me a push in the right direction? Thanks!

What if sunset is after 9pm? Or what if sunset is 4 pm. You want the lights to fade out for 5 hours? The number you are getting is in epoch time. And first of all 9PM is not a time that unix will understand. I assume you’re using a Webcore expression? (Should really be on the webcore forum but we’ll let it slide). If so, you want to put it in the correct format. I would do something like this.

(addHours($nextmidnight,-3)-$sunset) / 60,000 That should give you the number of minutes you’re looking for.

Don’t know what you are using but I would do it like this in webCoRE:

I tested it and it works: