Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 727737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:36:06+00:00 2026-05-14T06:36:06+00:00

I call the following function with Call GameTimer(FormatDate(objLiveCommentary(DateFirstStarted), WithTime), FormatDate(objLiveCommentary(DateSecondStarted), WithTime), Soccer) And it

  • 0

I call the following function with

Call GameTimer(FormatDate(objLiveCommentary("DateFirstStarted"), "WithTime"), 
               FormatDate(objLiveCommentary("DateSecondStarted"), "WithTime"), 
               "Soccer")

And it prints results as 23, 35, 64, 90. I want to take this result and store it as

CurrentGameTime = 

because I will save CurrentGameTime to my database. How can I do it?

Function GameTimer (FirstStarted, SecondStarted, GameType)

If GameType =   "Soccer"    Then
    DateFirstStarted    = DateDiff("n", FirstStarted, FormatDate(NOW(), "WithTime"))
    DateSecondStarted   = DateDiff("n", SecondStarted, FormatDate(NOW(), "WithTime"))

    If DateFirstStarted <= 45 Then
    Response.Write DateFirstStarted
    ElseIf DateFirstStarted <= 45 Then
    DateFirstStarted
    ElseIf DateSecondStarted <= 45 Then
    Response.Write DateSecondStarted + 45
    ElseIf DateFirstStarted <= 45 Then
    DateFirstStarted
    Else 
    Response.Write "90"
    End If  
End If

End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:36:06+00:00Added an answer on May 14, 2026 at 6:36 am

    To return the result of your Function you need to set the Functions return value:

    Function GameTimer(FirstStarted, SecondStarted, GameType)
        ...
        GameTimer = 90
    End Function
    

    Your GameTimer Function should look something like this:

    Function GameTimer(FirstStarted, SecondStarted, GameType)
        Dim result
        result = 90
    
        If GameType = "Soccer" Then
            DateFirstStarted = DateDiff("n", FirstStarted, FormatDateTime(Now(), 0))
            DateSecondStarted = DateDiff("n", SecondStarted, FormatDateTime(Now(), 0))
    
            If DateFirstStarted <= 45 Then
                result = DateFirstStarted
            End If
    
            If DateSecondStarted <= 45 Then
                result = DateSecondStarted + 45
            End If
        End If
    
        GameTimer = result
    End Function
    

    This would work, but it’s still not clean code.

    First, you should get rid of the GameType because what you actually want, is to determine the length of a period:

    Function GameTimer(FirstStarted, SecondStarted, PeriodInMinutes)
        Dim result
        result = PeriodInMinutes * 2
    
        DateFirstStarted = DateDiff("n", FirstStarted, FormatDateTime(Now(), 0))
        DateSecondStarted = DateDiff("n", SecondStarted, FormatDateTime(Now(), 0))
    
        If DateFirstStarted <= PeriodInMinutes Then
            result = DateFirstStarted
        End If
    
        If DateSecondStarted <= PeriodInMinutes Then
            result = DateSecondStarted + PeriodInMinutes
        End If
    
        GameTimer = result
    End Function
    

    Usage

    CurrentGameTime = GameTimer(FormatDateTime(objLiveCommentary("DateFirstStarted"), 0),
        FormatDateTime(objLiveCommentary("DateSecondStarted"), 0),
        45)
    

    A next step would be to replace the parameters FirstStarted and SecondStarted by an Array to allow games with thirds and quarters.


    Array of period start times

    Function GameTimer(Periods, PeriodInMinutes)
        Dim result
        Dim currenttime
        Dim i
    
        result = 0 '-- preset to zero --'
    
        For i = 1 To (UBound(Periods))
            currenttime = DateDiff("n", Periods(i), FormatDateTime(Now(), 0))
    
            If currenttime > 0 Then
                If (currenttime <= PeriodInMinutes * i) Then
                    result = currenttime + (PeriodInMinutes * (i - 1))
                Else
                    result = PeriodInMinutes * i
                End If
            End If
        Next
    
        GameTimer = result
    End Function
    

    Usage

    Dim CurrentGameTime
    Dim IceHockeyPeriods(3)
    
    IceHockeyPeriods(1) = "2010-04-15 19:30"
    IceHockeyPeriods(2) = "2010-04-15 20:00"
    IceHockeyPeriods(3) = "2010-04-15 20:30"
    
    CurrentGameTime = GameTimer(IceHockeyPeriods, 20)
    

    Edit

    Refactored to correct the flaw that between periods the full time is returned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to do the following: function main(callback) { $.ajax('server-side', function() { this.callback.call(hello);
I have the following function call: public static MvcHtmlString NavLinks( this HtmlHelper helper, IList<MenuItem>
I want to call the following function from my managed code: short LS_LoadConfig(LS_ID SensorID,LPVARIANT
I'd like to fetch each row when I call the following function: CpuReporting.getgridusage(300) This
I call the following function with a mouseover event but it's not working. My
I have the following function call from a thread: Thread Move = new Thread(){
Will GHC perform tail-call optimization on the following function by default? The only weird
I am using following function. Whenever i call it that time it will increase
I have the following function in a PHP script, which returns and API call:
I use the following call to openCV function to perform K-means algorithm: cvKMeans2(points, count,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.