Count DOWN Timer Field

  • When a new entry is put into my database I would like one of the fields to act as a count down timer from 2 hours to 0

    Once at 0 and if no one has reviewed the entry a flag would be raised and someone notified by e-mail. if someone has viewed the entry than that field get empted and the entry is flaged as accepted.

    I am displaying each new entry on a web page that is refreshed every minute but I am not able to figure out how to get the field to count down.

    Can anyone help me with this or maybe point me in the right direction.

    Thank You

     

  • Why not simply have two columns in the table, one for storing the time the entry was created and the other when the entry was reviewed. Then have your process check regularly for entries where creation date is more than 2 hours old and no review has been logged.

  • You don't make it count down. Add a datefield with default getdate().

    Then the query would be something like this :

    Select * from dbo.MyTable where DateField between dateadd(HH, -2, GetDate()) and GetDate()

    This would display everything that is over 2 hours old... You'll have to add another flag that says the row has been reviewed and include this in a where condition to filter those out too.

    Then you can run a job every X minutes on the server and if records are found, send a notification to the right person(s).

  • Damn I'm getting too slow for this .

    Gonna have to retire when I hit 3k.

  • >Remi Gregoire

    ...

    >Posts: #3002

    Too late for that as well it seems.

    Edit: And turned to 3003 while I was posting this.

  • #3004

    Yup. Gonna have to retire at 6k I guess .

    [EDITED]

    Almost 3100 now

  • Thank You very much for your response.

    With your input i have come up with the following code...Problem is I keep getting a expected End of Statement error. Basicly if the log is one hour old display the time in yellow, if it 2 hours old display it in red.

    What am I missing in this code to cause the End Statment error

    <% If ( DateDiff( "H", nextdate,  NOW() ))<="1" and(Recordset1.Fields.Item("status")) <> "1"

    Then RESPONSE.Write("<td nowrap><span class='style19'>") + (Recordset1.Fields.Item("timecreated"))

    END If

    ElseIf ( DateDiff( "H", nextdate,  NOW() ))=>"2" and (Recordset1.Fields.Item("status")) <> "1"

     Then  RESPONSE.Write("<td nowrap><span class='style17'>") + (Recordset1.Fields.Item("timecreated")) 

    END If

    Else RESPONSE.Write("<td nowrap><span class='style22'>Log Accepted") >

    %>

  • There's no initial condition for this statement :

    END If

    ElseIf (

  • Ok I got the following code to kind of work...Is it proper to use the expressions "<>" or "=>" for does not equal or is equal to or greater than?

     

     <% If ( DateDiff( "H", nextdate,  NOW() ))<="1" and (Recordset1.Fields.Item("status"))<>"1"

    Then RESPONSE.Write("<td nowrap><span class='style19'>") + (Recordset1.Fields.Item("timecreated"))

         If ( DateDiff( "H", nextdate,  NOW() ))=>"2" and (Recordset1.Fields.Item("status"))<>"1"

    Then  RESPONSE.Write("<td nowrap><span class='style22'>") + (Recordset1.Fields.Item("timecreated"))

    Else RESPONSE.Write("<td nowrap><span class='style19'>Log Accepted")

    %>

  • "" and "=>" or not the same thing... use them as required.

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply