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

  • SEARCH
  • Home
  • 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

Ask A Question

Stats

  • Questions 533k
  • Answers 533k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer AVM2 (AS3) movies cannot be loaded into AVM1 (AS1/2) movies.… May 17, 2026 at 12:32 am
  • Editorial Team
    Editorial Team added an answer AudioRecord is the class to read up on.... you specify… May 17, 2026 at 12:32 am
  • Editorial Team
    Editorial Team added an answer UPDATED: According to comments below, .NET limits arrays to 2GB… May 17, 2026 at 12:32 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I call the following function with a mouseover event but it's not working. My
Given the following function call in C : fooFunc( barFunc(), bazFunc() ); The order
I saw the following function call in Yacfe example : Visitor_c.vk_program { Visitor_c.default_visitor_c with
I'm using the following function call: var filesfound = filterSplit.SelectMany( filter => folder1.GetFiles( filter,
I have the following function call inside a jsp page. jQuery(function($){ $(#product).mask(99/99/9999,{placeholder: }); });
I have written the following function to calculate a check digit in R. verhoeffCheck
I'm trying to make a Jstree, the code for it is the following: $(function
Consider the following statements: int *pFarr, *pVarr; int farr[3] = {11,22,33}; int varr[3] =
I am trying to generate a piecewise symbolic function in Matlab. The reason it
I'm trying to implement a ring buffer with the following struct /*head, tail are

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.