on 12-05-2008 12:27 PM
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
Try
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
Try
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.
Regards,
Madhavi
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
9 | |
9 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.