time calculation

  • Thread starter Thread starter ibu007
  • Start date Start date
I

ibu007

Guest
i have two date/time fields

sdate (start date) 01/01/2006 14:30 - format(dd/mm/yyyy hh:mm)
edate (end date) 02/01/2006 14:31 - format(dd/mm/yyyy hh:mm)

i need to get answer in HH:MM (24:01)


pls help me

thnx best regards
ibu
 
Dim dtmStartTime As Date
Dim dtmEndTime As Date

Dim intTimeDiffInMinutes As Integer
Dim intHours As Integer
Dim intMinutes As Integer

dtmStartTime = "01/01/2006 14:30:00"
dtmEndTime = "02/01/2006 14:31:00"
intTimeDiffInMinutes = DateDiff("n", dtmStartTime, dtmEndTime)
intHours = Fix(intTimeDiffInMinutes / 60)
intMinutes = intTimeDiffInMinutes Mod 60

MsgBox Format(intHours, "00") & ":" & Format(intMinutes, "00")
 
thanks

ur great man

thank u very much
 
This syntax gave me "overflow" error message
dtmStartTime = "01/01/2006 14:30:00"
dtmEndTime = "02/01/2006 14:31:00"

I replaced it with
dtmStartTime = #01/01/2006 2:30:00 PM#
dtmEndTime = #02/01/2006 2:31:00 PM#

and it work fine now.
 
Try take the PM out and it should work it is down to the formatting of the code
 

Users who are viewing this thread

Back
Top Bottom