Comparing Time Values

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by coppo, Apr 21, 2006.

  1. coppo

    coppo

    Joined:
    Sep 7, 2004
    Messages:
    221
    Likes Received:
    10
    Location:
    Adelaide
    If this is metioned elsewhere .. apologies in advance, did not find it on a search though...

    A common question asked with the "logic engine" is to do with time,
    time values, using them.. and problems arising from them.

    In later versions of the "logic" help file in Piced darren has updated the listed
    information to make it easier .

    When comparing time values or even sunrise /sunset values all works well
    until it has to cross the dreaded "midnight" o clock.

    Problem being that midnight is seen as a ZERO value and computers see time values as an integers,
    so when it sees a zero value at midnight is affects how your code works or does not work.

    Short form answer:
    To correctly compare time values crossing over the midnight period:

    If (time >= "9:00PM") OR (time <= "7:00AM") then ...do something


    To correctly compare time values NOT crossing over the midnight period:

    If (time >= "7:00AM") AND (time <= "9:00PM") then ...


    Sunset and Sunrise can be substituted just as easily, as they are recognised
    by the logic engine as valid named time values.

    ==========================================
     
    coppo, Apr 21, 2006
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.