Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To Calculate Start And End Time


I feel like I should know this but I just cannot think of how to do this.

I want to calculate how long a user is in a particular form. So when they launch the form I store a NOW in txtTime (which is visible = False).

txtTime.text = Format(Now, "hh:mm:ss")

Then when they click the save button I want to calculate txtTime.text - Format(Now, "hh:mm:ss")

So something like this:
Code:strDurationTime = 14:32:00 - 14:39:01

But I am having trouble calculation a string (txtTime) with Now, plus I want the end result to be in seconds (421 should be the results if I calculated right from the above numbers)

I feel stupid for not know this... but if you could help I would appreciate it!

Thanks,
Adobe



Edited by - Adobe on 5/11/2005 5:30:51 AM




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Calculate Time Different?
Hello, Everyone:
I had times which is formatted as 12:00:00 Am. I want to cacualte its difference and add them together as following:

Code:
Dim monTimeInMorning As Date
Dim monTimeOutMorning As Date
Dim monTimeInAfternoon As Date
Dim monTimeOutAfternoon As Date
Dim monTotal As Double


monTimeInMorning = Range("D6").Value
monTimeOutMorning = Range("D7").Value
monTimeInAfternoon = Range("D8").Value
monTimeOutAfternoon = Range("D9").Value
'Sure it is wrong!!
'monTotal = DateDiff(monTimeOutMorning, monTimeInMorning) + DateDiff(monTimeOutAfternoon, monTimeInAfternoon)
How I can make it work? Thank you very much!
Charlie

Calculate Time
Hi all ,

Iam trying to do some time calculations.

start time : 9:45 am
end time :1:15pm
the result total should give me the difference and at the same time if the
start time is 3:30 pm
end time is 2:00 am

Need ur inputs in implementing this .... thanks

How To Calculate Time?
how can i change the minute value of my time? I'm thinkin' of adding a few minutes if it's not divisible by 5 (e.g. 5:05, 5:10, 5:15 and so on) i want the values to be 5 minutes only.. how can i do that?

Calculate Time
I am having trouble finding a format that allows me to have hours and minutes. I will be using it to calculate how many hours or minutes someone has worked on a piece of machinery...but the information does not come in with a start and stop time...it comes to me in the "number of minutes worked". Is there such a thing?

Time To Calculate...
Greetings, all. Is there an easy way to calculate the number of seconds and/or minutes b/w two times of day? Now, before you jump to the reply button, lemme explain: I have written TOD (time of day) HH:MM:SS PM to a field in a database, and logged a 'begin' statement in an adjacent field. The next row has a time, and an 'end' entry. See:

Begin.....12/12/00.....3:37:18 PM
End.......12/12/00.....3:38:07 PM

Now, how do I read those two fields (I can make these be TIME/DATE type or STRING type) and calculate elapsed time? There will eventually be hundreds of these, blah, blah, blah. AddTime and TimeDiff methods are balking, b/c there is no DATE (the 12/12/00 part) in the field-only the HH:MM:SS PM. Is this going to be a huge mess? If absolutely necessary (Grrr...) I can combine my DATE field and TIME fields which would ease my use of TimeDiff...but I'd rather leave them separated. Does this make any sense? Plz help if you understand.
-r

Calculate Time
hi

how can i making plus operation between two or three times like this :
00:00:25 + 00:00:15 + 00:01:00 = 00:01:40

please help

Calculate With Time
I know, thats too easy to be asked, but I don't find a soulution.
I have the value «2,25 Minutes» and I want to get «2Min 15Sec».
How Do I Do that?

Matt

Calculate Time Help
I need help with writting a code which will round a number to whole, using the INT statement.INT

Here is the code so far with example figures:

Dim Elapsedtime as Single

Elapsedtime = Val(txtDepartTime) - Val(txtEnterTime)

9.05 - 9.00 = 0.05

Therefore we need an int code that will round up the 0.05 to 1
or any other point number to a whole number ( e.g Elapsedtime 9.75 needs to be rounded up to 10)

Calculate Time
I have a problem. I need to calculate time in a project.
I am minusing one time from the other to work out total time spent on something. But my answer comes out as over .59 minutes e.g. 7.75 which should actually read as 8.15. How do I work it out? Need help as soon as possible. Thanks.

Calculate Time
1)How do i calculate time if time given as this format between this...

(HH:MM:SS:MS)
start = 12.30.33.123
end = 13.25.55.888

the time format given in mili-second.... as above...

i using datediff function but give me an error "mistype match" cox i using mili-second as well.


2) how do i convert to format? as below example given.

start = 12:00:30
end = 17:00:15

diff = ("s", start, end)

result : diff = 17985

how i convert to format HH:MM:SS if the result as above.

Calculate Time
Do anyone know or can provide me with an example of how i can calculate amount of hours between two time periods....

Example: 2/02/06 11:03:04pm  2/03/06 3:02:43am



How Can Calculate Time In Vb 6
how can calculate time in vb 6
like..(30:30+20:15)=50:45


How Can I Calculate Time In Vb6
vb 6
how can calculate time in vb 6
like..(10:30+20:15)


Need Calculate This Time
Hi Guys ,

am Newbie In this site its very cool and great anyway this my problem i need to calculate a time from text1 to text2

example:

time1=10:20 AM
time2=11:00 AM

I DID THIS CODE BUT SOME TIMES CALCULATE TRUE AND SOME TIMES WRONG


here in this pic its show the Number Of Hours And Minutes True
Pic1

here in this pic its show the Number Of Hours And Minutes Wrong
Pic2

the code is :
        
        Dim Time1, Teme2 As Integer
        
        Time1= DateDiff("H", CDate(TimeOffFrom), CDate(TimeOffTo))
        
        Time2= DateDiff("N", CDate(TimeOffFrom), CDate(TimeOffTo))
                
        NoOfHoursMinutes = lngHowLong & ":" & lngHowLong1

when you see the pic will understand it

thanks to all



Regards
Swidan


 

Edited by - Swidan on 3/26/2006 9:10:12 PM

Calculate Time
how to write code for claclate of time.
example:- 8:00:32 with 9:01:15.

using datediff function ? but how? i need some example.




Regards,
Wilson Chai

Calculate Time
Hello,

is there any way to calculate time by using SQL statement?
for example:

i am working to calculate how long (duration) between two time(in the same day), let say overtime hours.
The fields in my database are...

timein :- 14:00
timeout :- 18:00
totaltime : ?

i am expecting the result to be in minute(s).

please help me.


regards usin.

Calculate Elapsed Time
I need to subtact an out time from an in time in order to get minutes and seconds worked. I've found a way to give me a total in the format of seconds so so someone worked 365 seconds. Then is there a formula to break this down into minutes and seconds or does anyone know of a better way to subtract the time in from the time out to get elapsed time?

Howto Calculate Time
What i want to do is calculate the time that someone is logged in.
I dont know what to use, i now user Strings, should i use Date/Time?

Either way i get an error "Type mismatch" / "Types are not the same" / "Types do not match" something like this.


Code:
Dim tmLoginTime As String
Dim tmOnlineTime As String
Dim tmNow As String

tmLoginTime = Me.LoginTime.Value
tmNow = Time
tmOnlineTime = tmLoginTime - tmNow
Me.OnlineTime.Value = tmOnlineTime

Calculate The Time Difference?
Hi,

Is there a built-in function to calculate time difference down to min/sec? from two data/time fields

If not, how can do this?


Thanks!

Calculate Time (24-hour)
for example:
time-A: 1749
time-B: 1555
how to count: how many minutes between time-A and time-B?
or is there VB library can do for this?

Calculate Time Difference
Dear friends

I want to calculate difference b/w two times:

Thanks

Maskedbox Time Calculate
i am stuck on this:
I got three maskEdboxes

maskEdStart
maskEdEbd
maskEdTotal

with time format "hh:mm"

HOW can i calculate this:
maskEdTotal = maskEdEbd - maskEdStart
(00:30=15:00-14:30)

Thanks!!

Calculate Time Remaining
This isn't specifically a VB problem, but I'm sure someone here can answer it.

I need to estimate the time remaining for a process. The variables which I want to calculate it with are the completion ratio (0 - 1), and the time that has elapsed since the process began.

From this I should be able to calculate how many more seconds remain, right? Well I don't know the maths of it, so can anyone help me out?

Calculate Time Difference
hello! i have a bit of a problem. I am storing the start time and finish time of when users clock in and clock out, but i dont know how to calculate the time difference inbetween them. it is for a simple wage calculater. I was trying to user timers but there were problems with if the computer went to hibernate and that.

Thanks in advance!!

Calculate Time Code
Const ConMinCharge As Currency = 10
Const ConAddCharge As Currency = 2.5
Const ConMaxCharge As Currency = 50

Private Sub cmdCalcCharge_Click()
If lblTotHrsParked = 24 Then
lblTotAmtDue = ConMaxCharge
ElseIf lblTotHrsParked > 24 Then
lblTotAmtDue = lblTotHrsParked - 24 * ConAddCharge + ConMaxCharge
ElseIf lblTotHrsParked <= 3 Then
lblTotAmtDue = ConMinCharge
ElseIf lblTotHrsParked > 3 < 24 Then
lblTotAmtDue = lblTotHrsParked - 3 * ConAddCharge + ConMinCharge
End If
End Sub

Private Sub cmdExit_Click()
End
End Sub

Private Sub cmdHoursParked_Click()
lblTotHrsParked.Caption = FormatDateTime(vbShortTime)
lblTotHrsParked = txtCarTaken - txtCarParked

If lblTotHrsParked > 0.59 Then
lblTotHrsParked = lblTotHrsParked - 0.6 + 1
End If
End Sub

How To Calculate The Time Difference
Does anybody know how to calculate the time difference between (for example: 01:00 PM and 02: AM)?
I've set 2 variables:

StartTimeValue = Format(MyStartTime, "hh")
EndTimeValue = Format(MyEndTime, "hh")

'StartTimeValue will return 13 when 01:00 PM is set.
'EndTimeValue will return 02 when 02:00 AM is set.

Now how can I get the time difference? Is this format
I'm using ok, or should I use "hh:mm" for the return
value?

thx, sub-zero


Visual Studio 6.0 Enterprise Edition

Calculate The Difference Btw Time And Add Them Together
hi,

i'm a new beginner for VB. so need some help.
i'm collaborating VB with Excel.
tis is wat i roughly want to do.
calulate the time interval in the cells. and add all the intervals together.

time in time out Difference
10:00 11:00 1 hr
11:00 13:50 2 hr 50 mins

Sum 3 hr 50 mins

i tried to format the cells in excel as TIME.
but after adding all of them up, it doesn't work the way i wanted.
i guess the only help is to use VB.
thx to any1 in advance.
i'll provide more information if its needed.
thx

jiawen

How Can Calculate Time Long In Vb 6
how can calculate time in vb 6
like..(30:30:00+20:15:00)=50:45:00

30 hours and 30 minutes + 20 hours and 15 minutes

i use this


Dim Time1 As String
    Dim Time2 As String
    Dim Hours As Integer
    Dim Minutes As Integer
    
    Time1 = "30:30"
    Time2 = "20:45"
    
    Hours = CInt(Split(Time1, ":")(0)) + CInt(Split(Time2, ":")(0))
    Minutes = CInt(Split(Time1, ":")(1)) + CInt(Split(Time2, ":")(1))
    
    Hours = Hours + CInt(Minutes / 60 - 0.5)
    Minutes = Minutes Mod 60
    
    Debug.Print Hours & ":" & Minutes


but if the number is long in run i have error " over flow "

like..(40644:30:00+20:15:00)=406024:45:00

40644 hours and 30 minutes + 20 hours and 15 minutes



Calculate Ammounts Of Time
How would I calculate the ammount of time it would take to go a certain distance. I have a value of 1004(miles) and I'll be going at a rate of 900 (miles an hour) I want to divide 1004 by 900 and display the number of hours that is into a label.

y = 1004/900
y = 1.12
lblEFT.caption = ???? HH:MM

How To Calculate Minutes Into Time
If I have a var that has 243 in it, how would I calcualte that to minutes.

I would want it to read 0:04:03.

Thanks,
Adobe



Edited by - Adobe on 5/10/2005 1:13:31 PM

Calculate Finishing Time
Hi all
      After I could display the correct time format, I run into more problems. The time showing in the label never went to zero. I couldn't figure it out. If anyone did something like this beforem, please help me out. Thanks a lot in advance.

The example can be downloaded from th post below



Edited by - prapon77 on 11/10/2004 11:20:31 AM

Want To Calculate Time Diff
ok i have a table with a start time and a finish time how do i get the diff between the two
and where do i do it
cheers

How To Calculate Time In Milliseconds
i would like to know how to calculate time in milliseconds using mediaplayer 7.. i have writen code to veiw the elapsed/remain time of the mp3 file which is playing currently.. but it show the time using only mins and seconds..
i would appriciate any helps from you.. thanks ..

How To Calculate The Period Of Time For A Loop
I have a simple running loop in my code, which is shown below

Do While ((recieved_data <> "ACK") And Not (time = 300000))
recieved_data = MSComm1.Input
time = time + 1
Loop

Is there any way of calculating how long this count will take, maybe using the speed of the computer to calculate the time the loop goes for. Using a stopwatch, this loop takes on average 3.55 seconds.

And before you mention a timer, they don't work when your using a do while loop. They just can't seam to be accessed.

VB Calculate Time To Pay Off A Home Loan
Hi all, just a quick one

Just wondering if anyone knows how to calculate how long it will take to pay off a loan (preferably in months) if you are paying x interest which is calculated on the amount owing at the end of each day.


so for example if i owe $400 and i am making repayments of $10 per month and 10% interest, how many months will it take to pay off the loan.


If anyone knows how to do this... please help, its killing me trying to work it out.

Thanks for your time and consideration.

Mojoinst

Calculate Time In Crystal Report 9.0
I am trying to make report from Time Clock punches. Data is stored in table in 4 columns; EmpID, Date, Punch and InOut
-I want to make report where I will group by EmpID and Date with daily total of time and weekly total.
I already made grouping and works fine but I do not have idea how I can make calculation of time. I tried wiht using Basic syntax in formula editor but I have error in code.
Here is my code.
_______________________________________________________________
Dim d1(), d2(),s1,s2,t As Date

IIf {ClockP.Pflag}="In", d1()=CDateTime({ClockP.Punches}, d2()=CDateTime({ClockP.Punches})
s1=Sum(d1())
s2=Sum(d2())
t = s2-s1
_______________________________________________________________

Does anybody have idea how I can make those totals. Do you have any good example of Basic syntax.



Here is example of data;
EmpID Pdate Punch Inout

21 2/13/2004 2/13/2004 7:48:38 AM In
21 2/13/2004 2/13/2004 10:03:56 AM Out
21 2/13/2004 2/13/2004 3:53:46 PM In
21 2/13/2004 2/13/2004 5:07:01 PM Out
18 2/14/2004 2/14/2004 8:39:13 AM In
18 2/14/2004 2/14/2004 12:59:31 PM Out
18 2/14/2004 2/14/2004 2:08:27 PM In
18 2/14/2004 2/14/2004 4:01:03 PM Out

Calculate/Estimate A Process Time
how can you calculate/estimate the time it will take a process to complete.
for example , some applications like NAV will let you know how long it'll take to scan a drive.

Calculate Upload / Download Time
I want to let the user know approximately how much time it is going to take to upload or download a file that they have selected. So how can I detect network connection type and speed and average upload/download speed ?

Calculate Date/time Difference
hi everyone,

how do i calculate the difference between #January 27, 1993 17:04:23# and #January 26, 1995 02:49:36# ? Which function should I use..?

Many thanks in advance.

Calculate Code Execution Time?
How do I calculate time taken by a piece of code to execute (in milliseconds). I know its a firly simple task but I forgot how to do it.

Please help me

Kinjal

The Best Way To Calculate The Difference Time Between 2 Times...
I will calculate the difference time between 2 times string>>
Like 2003-10-1 10:10 and 2003-10-1 10:20
the first time string is 2003-10-1 10:10,the second time string is 2003-10-1 10:20.the calculated difference time is 10 minutes.
How i can do it with vb??...

Calculate Time Difference Between Two Dates
Hi folks!,

I need a script which can do this:
- Calculate the difference in minutes between two date/time.

I now... you are going to say that i need to use de datediff function, but here is the trick.

I need to calculate the time based on working hours using working days and time.

For example, suppose that you work monday to friday from 9:00am to 6:00pm and you have a task and you need to know how much time have you spent on it.

The task arrived at your email at 7:00pm on Sunday... so you will start to work on it at 9:00 am on Monday.

If you finish the job on Wednesday at 10:00 you had spent 19 hours on the project... datediff will say 63 hours.

Regards. German
PS: Sorry for any grammar or syntax error, englush it's not my native language.

How Do I Calculate Average Time In Listbox
hmm.. i would like to seek some advice on calculating average in listbox...

Below is he screen shot of my program.. Under the queue time listbox, i would like to find out the average of the queue time...
and input the result in the average queue time listbox..

the result should be auto-generated when the application is run...





Edited by - [cK] on 7/14/2004 8:01:41 PM

Calculate TextBox Width At Run-time
I have a textbox that is loaded with various lines of different lengths.
Firstly, I find the longest line of text, and then I use that TextWidth to set the width for the textbox.
The only problem, is it doesn't work. :lol:

Scalemode is set to 1 (Twips)

Code:Dim tmpWidthStr As Integer
Dim WidthStr As Integer
Dim BorderWidth As Integer

BorderWidth = ((GetSystemMetrics(SM_CXBORDER)) * Screen.TwipsPerPixelX) * 2

tmpString = frmPrintSyll.txtAikidoText.Text

tmpstr2 = Split(tmpString, vbCrLf)

For ctr = 0 To UBound(tmpstr2)
    tmpWidthStr = frmPrintSyll.TextWidth(tmpstr2(ctr))
    If tmpWidthStr > WidthStr Then
        WidthStr = tmpWidthStr
    End If
Next

'...set width of txtaikidotext
frmPrintSyll.txtAikidoText.Width = frmPrintSyll.TextWidth(WidthStr + BorderWidth + 10)

Calculate The Difference Btw Time And Add All E Differences Together
hi,

i'm a new beginner for VB. so need some help.
i'm collaborating VB with Excel.
tis is wat i roughly want to do.
calulate the time interval in the cells. and add all the intervals together.

time in    time out    Difference
10:00    11:00    1 hr
11:00    13:50    2 hr 50 mins
         
     Sum 3 hr 50 mins

i tried to format the cells in excel as TIME.
but after adding all of them up, it doesn't work the way i wanted.
i guess the only help is to use VB.
thx to any1 in advance.
i'll provide more information if its needed.
thx

I Want Function That Calculate Minute From Given Time
hi

    i want function that returns minute of given time. one another function that give me time 1 to 12 hours, not 1 to 24 hours.
    or function that convert 1 - 24 hours in to 1 - 12 hours

" something done that makes u something"

To Calculate The Difference Between Two Time Variables
i want to calculate the difference between two time variables
i need ur help since i'm not getting the result correctly    
actually i'm getting the result differently in hours,minutes & seconds but not collectively as 2 hours : 20 minutes : 45seconds
plz help

Calculate Time Duration Of Wav File
Hello everybody

Can anybody tell he how can we calculate the time duration for a wav file

Thanks


Mind is faster than Wind --- Mahabharat

How Can I Calculate The Sum Of (Date/Time) Hours?
Friends,

How can I calculate the sum of hours?

Working hours were stored in a database of SQL Server 2000.

Column Name    : WorkingHours
Data type        : DateTime

Values:
05:30
04:15
10:30
13:00

I want to display the sum of working hours (33:15) in a DTPicker control.

Suresh

Copyright © 2005-08 www.BigResource.com, All rights reserved