Internet PLC Forum

General => Technical support => Topic started by: jurg1505 on March 17, 2014, 01:00:35 AM

Title: How to compare time with DM value
Post by: jurg1505 on March 17, 2014, 01:00:35 AM
How can i compare the time with a DM value ?

SETLCD 1,11,"| "+STR$(TIME[1])+":"+STR$(TIME[2],2)+":"+STR$(TIME[3],2)+""

if DM[1] >= 0 AND DM[1] < 2400 AND DM[1] <> load_eep16(100) AND then                
save_EEP16 DM[1],100
else DM[1] = load_eep16(100)
ENDIF

if TIME >= load_eep16(100) then

DM[1] is always  4 digits
Title: Re:How to compare time with DM value
Post by: support on March 18, 2014, 01:45:46 PM
Do you mean you want the hour and minute only? You could assemble the number into four digit using TIME[1] and TIME[2]


E.g.  T  = TIME[1] * 100 + TIME[2]

So TIME[1] will be from 0000 to 2359


Alternatively you can also use STATUS(18) to read the clock as a 6 digit value and you can divide it by 100 to remove the seconds so that you get a 4 digit value.

E.g. T = STATUS(18)/100

You can then use T to compare against your DM values.
Title: Re:How to compare time with DM value
Post by: Philippe Parmentier on March 18, 2014, 04:13:07 PM
The other solution is to use a DM32 variable that can easily handle the 6 digits of the full time from 000000 to 235959