Skip to Content
author's profile photo Former Member
Former Member

Date & Time Calculation

Hi All,

In my screen i have the Attended date ,Attended time, Completed Date and Completed time. In the Total Stopagge in mins i want to calulate the total time used in mins including the date.

In my code it is not working correctly so please correct me where i go wrong:-

''' <summary>

''' Stopage In Mins Calulation

''' </summary>

''' <returns></returns>

''' <remarks></remarks>

Private Function StPInMinsCalculation() As String

Dim oFromTime, oToTime As DateTime

Dim oFromDate, oToDate As Date

Dim oDateDiff As Integer

Dim oDuration As String


oFromTime = Convert.ToDateTime(Date.Parse(oAttTimeTxt.String))

oToTime = Convert.ToDateTime(Date.Parse(oCmpltTimeTxt.String))

oFromDate = oAttDtTxt.String

oToDate = oCmpltDtTxt.String

oDateDiff = DateDiff(DateInterval.Day, oFromDate, oToDate)

Dim runLength As System.TimeSpan = oToTime.Subtract(oFromTime.ToShortTimeString)

Dim secs As Integer = runLength.Seconds

Dim minutes As Integer = runLength.Minutes

Dim hours As Integer = runLength.Hours

Dim Days As Integer = runLength.Days

oDuration = runLength.Hours * 60 + runLength.Minutes

Catch ex As Exception

Throw ex

End Try

Return oDuration

End Function

  • Item Event *******

If (pVal.ItemUID = "TxtCmplTim") And pVal.CharPressed = Keys.Tab And pVal.BeforeAction = False Then

Dim StpInMins As String


StpInMins = StPInMinsCalculation()

oTotStpTxt.Value = StpInMins

oParentDB.SetValue("U_stopmin", oParentDB.Offset, oTotStpTxt.Value)

Catch ex As Exception

Throw ex

End Try

End If

Thanks in Advance.



Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 09, 2008 at 11:40 AM

    Hi Madhavi

    i was looking at your code, but there are somethings I dont understand:

    u dont use oDateDiff as well as secs, minutes, hours and Days and you also better post the DateDiff method

    and finally a basic question about what u need 😊 Is that the difference in minutes between two datetimes ??

    if so u better create two datetime objects with the date and the time you get from your form and than calulate the difference!!

    Edited by: Rui Pereira on Dec 23, 2008 4:17 PM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.