-
Nov 20th, 2013, 06:22 AM
#1
Thread Starter
PowerPoster
DIFF in hours and minutes
i need to have a diff in hours and minutes from this two time and store result in var Hour_Diff .... how to?
example diff time from 00.12 and 14.45
note:
return the result in HH.MM format
tkx.
-
Nov 20th, 2013, 06:29 AM
#2
Re: DIFF in hours and minutes
This is what the DateDiff function is for.
It can return the difference between two DateTime variables in years,days, seconds, etc (look it up in the Help)
If you return the difference in seconds you can easily calculate the number of hours and minutes and display it like you want.
-
Nov 20th, 2013, 08:03 AM
#3
Re: DIFF in hours and minutes
An example using a textbox that includes a date/time:
Code:
Private Sub Command1_Click()
MsgBox DateDiff("n", Date, CDate(Text1.Text)) 'where 'n' represents minutes
End Sub
Private Sub Form_Load()
Text1.Text = Format(Now, "yyyy/mm/dd hh:mm")
End Sub
-
Nov 20th, 2013, 08:23 AM
#4
Thread Starter
PowerPoster
Re: DIFF in hours and minutes
Originally Posted by SamOscarBrown
An example using a textbox that includes a date/time:
Code:
Private Sub Command1_Click()
MsgBox DateDiff("n", Date, CDate(Text1.Text)) 'where 'n' represents minutes
End Sub
Private Sub Form_Load()
Text1.Text = Format(Now, "yyyy/mm/dd hh:mm")
End Sub
i not completlly understand, sorry.
admit have
dim t1 as date, t2 as date
dim Hour_Diff as date
t1=0.12
t2=14.26
i need in Hour_Diff the diff between t1 and t2 in the format 00.00
var Hour_Diff
-
Nov 20th, 2013, 08:49 AM
#5
Re: DIFF in hours and minutes
Do some tests yourself that's the best way to learn.
Look up the help for TimeSerial, DateSerial and DateDiff.
Do some experiments and try to write your own code.
-
Nov 20th, 2013, 09:35 AM
#6
Re: DIFF in hours and minutes
JG
... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...
-
Nov 20th, 2013, 10:12 AM
#7
Thread Starter
PowerPoster
Re: DIFF in hours and minutes
Originally Posted by jggtz
w0W!!!! TKS.
RESOLVED!
But now if i wauld to use a ">" operator i need a particular set of variable, or i can use a simple expression:
if t2>t1 the stop
or?
-
Nov 20th, 2013, 10:32 AM
#8
Re: DIFF in hours and minutes
Try it, do it, test it! Learn!
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
|