-
Aug 21st, 2014, 03:13 PM
#1
Thread Starter
Enjoy the moment
[RESOLVED] calculate total minutes between time value
i am trying to calculate between two time values with a single click
i tried to do something but no luck
Code:
Private Sub Command1_Click()
Dim TimeDiff As Long
Dim StartDate As Date
Dim EndDate As Date
EndDate = Time
TimeDiff = DateDiff("n", StartDate, EndDate)
TimeIN.Value = StartDate
TimeOut.Value = EndDate
TxtTotalWorked.Text = TimeIN.Value + TimeOut.Value
End Sub
no idea what to do
any help will be appreciated
regards
salsa31
Last edited by salsa31; Aug 21st, 2014 at 03:34 PM.
-
Aug 21st, 2014, 03:22 PM
#2
Re: calculate total minutes between time value
TimeDiff will have the number of minutes but in you code you hasn't initialized StartDate so that will have a default time of midnight.
-
Aug 21st, 2014, 03:28 PM
#3
Thread Starter
Enjoy the moment
Re: calculate total minutes between time value
TimeDiff will have the number of minutes but in you code you hasn't initialized StartDate so that will have a default time of midnight.
hey Mark of course you know that this code dosnt work at all
i used once datediff, i realy forget this calculation method
i realy dont know what to do
-
Aug 21st, 2014, 03:34 PM
#4
Re: calculate total minutes between time value
Of course it works. It gives you the time from midnight to the current time. If that isn't what you want then you have to adjust your variables accordingly.
Code:
Private Sub Command1_Click()
Dim TimeDiff As Long
Dim StartDate As Date
Dim EndDate As Date
EndDate = Time
TimeDiff = DateDiff("n", StartDate, EndDate)
MsgBox "The number of minutes between " & StartDate & " and " & EndDate & " is " & TimeDiff
End Sub
-
Aug 21st, 2014, 03:39 PM
#5
Thread Starter
Enjoy the moment
Re: calculate total minutes between time value
i am trying to calculate between
timein.value & timeout.value and display the results in [minutes]
TxtTotalWorked.Text needs to show me the total in minutes between this [timein.value & timeout.value]
-
Aug 21st, 2014, 03:53 PM
#6
Re: calculate total minutes between time value
So what are TimeIn.Value and TimeOut.Value. Are these coming from a control, a class.........I have no idea what TimeIn and TimeOut are.
-
Aug 21st, 2014, 04:06 PM
#7
Thread Starter
Enjoy the moment
Re: calculate total minutes between time value
it is a dtpicker that its format is dtptime
e.x
this is TimeIn.Value 21:00:00 this is TimeOut.Value 22:00:00
i want TxtTotalWorked.Text to calculate between the two of them
here the calculation is 60 minutes
-
Aug 21st, 2014, 04:21 PM
#8
Re: calculate total minutes between time value
Code:
Private Sub Command1_Click()
Dim TimeDiff As Long
TimeDiff = DateDiff("n", TimeIn.Value, TimeOut.Value)
TxtTotalWorked = TimeDiff
End Sub
-
Aug 21st, 2014, 04:28 PM
#9
Thread Starter
Enjoy the moment
Re: calculate total minutes between time value
exactly!!
tnk you very much mark
i appreciate your help
-
Aug 21st, 2014, 11:51 PM
#10
Re: [RESOLVED] calculate total minutes between time value
You could even shorten that more by removing the un needed variable from the mix
Code:
Private Sub Command1_Click()
TxtTotalWorked = DateDiff("n", TimeIn.Value, TimeOut.Value)
End Sub
-
Aug 22nd, 2014, 05:08 AM
#11
Thread Starter
Enjoy the moment
Re: [RESOLVED] calculate total minutes between time value
You could even shorten that more by removing the un needed variable from the mix
tnk you sir
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|