Real Software Forumshttp://forums.realsoftware.com/ time calculationhttp://forums.realsoftware.com/viewtopic.php?f=13&t=29307 Page 1 of 1

 Author: Rivo [ Thu Jul 30, 2009 10:27 am ] Post subject: time calculation Hi,I'm trying to calculate the time duration to find the minute differences,I've found some code on VB..`Private Function TimeDiff(Time1 As String, Time2 As String) As String Dim MinsDiff As String Dim TheHours As String MinsDiff = DateDiff("n", Time1, Time2) 'If midnight is between times MinsDiff = IIf(MinsDiff < 0, MinsDiff + 1440, MinsDiff) TheHours = Format(Int(MinsDiff / 60), "00") MinsDiff = Format(MinsDiff Mod 60, "00") TimeDiff = TheHours & ":" & MinsDiffEnd FunctionPrivate Sub Command1_Click() Dim x As String x = TimeDiff(Text1.Text, Text2.Text) MsgBox xEnd Sub`I just wanna know if its possible to convert it to rb..ThanksRegards,Rivo

 Author: Bob Keeney [ Thu Jul 30, 2009 10:46 am ] Post subject: Re: time calculation Sure. Look up the totalseconds property for the Date class.Since you know how many seconds are in a minute the resulting calculation is easy.

 Author: Rivo [ Fri Jul 31, 2009 7:00 am ] Post subject: Re: time calculation I did, but I have a problem if I have to do calculation which is separated by ":" signActually, I did it in VB, just dunno how to make it in RB,this is exactly what I Need`Dim Str1\$, Str2\$, Str3\$, Str4\$Text2.Text = DateTime.DateDiff("n", Text1.Text, Label1.Text)Str1 = Text2.Text \ 60Str2 = Text2.Text Mod 60If Str1 > 24 Then Text3.Text = "More than a day.."Else Text3.Text = Str1 & " hours & " & Str2 & " minutes" Text3.Text = Format(Text3.Text, "hh:mm") If Val(Text2.Text) > 480 Then Label2.Caption = Text2.Text - 480 Str3 = Label2.Caption \ 60 Str4 = Label2.Caption Mod 60 Text4.Text = Str3 & " hours & " & Str4 & " minutes" End IfEnd If`regards,Rivo

 Author: simulanics [ Sun Apr 29, 2012 10:31 pm ] Post subject: Re: time calculation 3 years later asking the same question and no answer exists yet :-p`Function MinDiff(xSQLDateTime as String) As Integer dim base as new date dim now as new date now.SQLDateTime = xSQLDateTime dim diffInSeconds as double = abs( now.totalseconds - base.totalseconds ) dim minsBetween as integer = diffInSeconds/60 Return minsBetweenEnd Function`Thanks to timhare

 Page 1 of 1 All times are UTC - 5 hours Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/