displaying current minute of a soccer match
I could not figure out the logic I would need to display a current minute of a soccer match. I have three fields in the database.
DateFirstStarted DateSecondStarted DateFullEnded
I should enter DateFirstStarted when the game starts and on the website. i.e. game starts at 7:05pm, on 7:25pm it should display '20 on the website. However, it should stop on the 45th minute. Then, I enter DateSecondStarted when the second half starts and should count from 46 to 90 and freeze there. Do I make sense? How can I do it? Is there a better way to do this?
Something not too complicated should do it. I will update start date of first half and start date of second half myself.
Here is how I tried it. I dont get an error but its not working. Any suggestion appreciated.
DateFirstStarted = objLiveCommentary("DateFirstStarted")
DateFirstEnded = DateAdd("n", 45, DateFirstStarted)
DateSecondStarted = objLiveCommentary("DateSecondStarted")
DateSecondEnded = DateAdd("n", 45, DateSecondStarted)
If DateFirstStarted => NOW() => DateFirstEnded Then
Response.Write "first half"
ElseIf DateSecondStarted => NOW() => DateSecondEnded Then
Res开发者_运维问答ponse.Write "second half"
End If
Have a look at the DateDiff function?
You pass it two datetimes and it will give you the total amount of mins / seconds / hours etc between the two values.
http://www.w3schools.com/vbScript/func_datediff.asp
E.g.
If DateDiff("n",StartOfMatch,Now()) < 45 Then
FirstHalf = True
Elseif DateDiff("n",StartOfMatch,Now()) >= 45 Then
SecondHalf = True
Else
MatchEnded = True
End If
Hope this helps you?
C
精彩评论