Page 1 of 1
Day as value

Posted:
Thu Oct 27, 2016 1:54 pm
by AndrewB
How do I check for the day of the week.
I want to check if it's a week day?
if date.dayofweek >=1 and date.dayofweek <=5 then dosomething
Re: Day as value

Posted:
Thu Oct 27, 2016 6:52 pm
by AndrewB
Ok I had found that that case dependant. DatOfWeek.
I have tried if (((time.hour >= Starthour) and (time.minute >= Startmin)) and ((time.hour < Stophour) and (time.minute < Stopmin))) then
But this does not work. What am I doing wrong on this?
If i ONLY HAVE MINS OR HOUR ITS OK.
Re: Day as value

Posted:
Fri Oct 28, 2016 10:18 am
by Jerry Messina
Firewing isn't case sensitive.
It's best to post a complete example of something that you're trying to do, otherwise it's hard to comment on what's working or not.
Re: Day as value

Posted:
Fri Oct 28, 2016 11:28 am
by AndrewB
Jerry why does
if (((time.hour >= Starthour) and (time.minute >= Startmin)) and ((time.hour < Stophour) and (time.minute < Stopmin))) then
if time.hour >= Starthour and time.minute >= Startmin and time.hour < Stophour and time.minute < Stopmin then
not work and
If time.hour >= Starthour and time.hour < Stophour then
If time.minute >= Starmin and time.minute < Stopmin then
works
Re: Day as value

Posted:
Fri Oct 28, 2016 8:42 pm
by Jerry Messina
- Code: Select all
Public Structure RtcTime
dim Second As Byte ' Second (0..59)
dim Minute As Byte ' Minute (0..59)
dim Hour As Byte ' Hour (0..11 or 0..23)
End Structure
dim time as RtcTime
dim Starthour, Startmin, Stophour, Stopmin as byte
Sub Main()
time.hour = 2
time.Minute = 34
starthour = 1
startmin = 2
stophour = 3
stopmin = 45
if (((time.hour >= Starthour) and (time.minute >= Startmin)) and ((time.hour < Stophour) and (time.minute < Stopmin))) then
high(PORTB.0)
end if
If time.hour >= Starthour and time.hour < Stophour then
If time.minute >= Startmin and time.minute < Stopmin then
high(PORTB.0)
end if
end if
End Sub
works the same for me. What's your code look like?
Re: Day as value

Posted:
Sat Oct 29, 2016 9:25 am
by AndrewB
Thanks Jerry yes it works I had changed a few things and now that looks like it works.
I had to change stop.hour < stophour to stop.hour <= stophour
I will post the program when I've tidy'd up

I have to work out functions to cut down some of the subs down.
Re: Day as value

Posted:
Sat Oct 29, 2016 10:59 am
by AndrewB
It works if the realtime is before the start and stop times.
If the starthour/startmin is set before the real time it does not seem to go past the startmin/stopmin check.
I think it needs the hours and minutes combined into one variable to compare.