Date Time Calculations - Need Some Direction

C

cehrenre

Hello -

I am new to Excel VBA programming and need some assistance. I have a report
that contains several fields which I load into MS-Excel. On this report there
are 2 columns that contain Date and Time stamps. The first date represents
the date and time stamp when the item was added to the log. The second is the
date and time stamp when the item was resolved.

My problem - I need to calculate the elapsed time in hours:minutes between
the two dates. I need to do this in VBA as it is part of a report that is
generated by click of a command button.

I have searched the help files and have found DateDiff and a few other
functions to parse dates but I dont see a straight forward solution. Can
anyone help me or point me to an example or two on how to do this?

Thanks for your help.
 
C

cehrenre

The date and time fomat stored in the two column in my sheet is as follows:

10/21/2006 2:11:00 PM
 
T

Tom Ogilvy

dt2 = cdate("10/21/2006 2:11:00 PM")
dt1 = cdate("10/19/2006 5:00:00 PM")
dif = (dt2 - dt1)
? dif
1.88263888888469
h = int(dif*24)
m = (dif*24 - h) * 60
? h, m
45 10.9999999939464

' or
? application.Text(dt2-dt1,"[h]:mm")
45:11
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top