Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Time when TimeIntoInterval(0,120,sec) ?


MortenS Sep 8, 2011 12:16 PM

Hi there

Is it posible to "calculate" the time when TimeIntoInterval(0,120,sec) is true ?


Sam Sep 8, 2011 02:47 PM

If you modulo the number of seconds into the day by 120 and the result is 0 then the statement is true.

If (Seconds_Into_The_Day) MOD 120 = 0

In other words

(midnight) --->
00:00:00, 00:02:00, 00:04:00, 00:06:00 ...


MortenS Sep 8, 2011 05:38 PM

thanks


Sam Sep 8, 2011 11:15 PM

MortenS,

Where you hoping that it did something different? If so, maybe we can help point out a solution.


MortenS Sep 9, 2011 08:57 AM

Dear Sam

My intention was to know the time (timestap) when TimeIntoInterval(0,120,sec) happens in the future.

/Morten


aps Sep 9, 2011 09:17 AM

Sam's rules are correct, but a couple of extra details. The time used is the time of the start of the scan, plus the function will only return true once at the start of the period when the time condition is met, e.g. with a one sec scan rate, 0 into a 5 min period is set once every 5 mins not 60 times at the beginning of a 5 min period.


Sam Sep 9, 2011 03:16 PM

Two potential methods for looking at when the next interval is going to happen. Could mix and match some of the concepts if needed.


Const Interval = 120 'seconds
Public SS90 As Long
Public NextSS90 As Long
Public NextDate As String * 23

DataTable (TimeTable,True,1)
TableHide
Sample (1,NextSS90,Nsec)
EndTable

BeginProg
Scan (1,Sec,0,0)
If TimeIntoInterval (0,Interval,Sec) Then
SS90 = Public.Timestamp(1,1)
NextSS90 = SS90 + 120
CallTable (TimeTable)
NextDate = TimeTable.NextSS90(4,1)
EndIf
NextScan
EndProg

------------------------------------------


Const Interval = 120 'seconds
Public SecTilNext As Long

BeginProg
Scan (1,Sec,0,0)
SecTilNext = Interval - (Public.Timestamp(4,1) MOD Interval)
If TimeIntoInterval (0,Interval,Sec) Then
'do something
EndIf
NextScan
EndProg


MortenS Sep 14, 2011 11:18 AM

Hi Sam

A mix of those did the job

Const Interval = 120 'seconds
Public SS90 As Long
Public NextSS90 As Long
Public NextDate As String * 23
Public SecTilNext As Long

DataTable (TimeTable,True,1)
Sample (1,NextSS90,Nsec)
EndTable

BeginProg
Scan (1,Sec,0,0)
SecTilNext = Interval - (Public.Timestamp(1,1) MOD Interval)
NextSS90 = Public.Timestamp(1,1) + SecTilNext
CallTable (TimeTable)
NextDate = TimeTable.NextSS90(1,1)
NextScan
EndProg

Thanks

Log in or register to post/reply in the forum.