PC Review


Reply
Thread Tools Rate Thread

Date Time Calculations - Need Some Direction

 
 
=?Utf-8?B?Y2VocmVucmU=?=
Guest
Posts: n/a
 
      3rd Nov 2006
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.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Y2VocmVucmU=?=
Guest
Posts: n/a
 
      3rd Nov 2006
The date and time fomat stored in the two column in my sheet is as follows:

10/21/2006 2:11:00 PM

"cehrenre" wrote:

> 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.

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      3rd Nov 2006
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

--
Regards,
Tom Ogilvy


"cehrenre" wrote:

> The date and time fomat stored in the two column in my sheet is as follows:
>
> 10/21/2006 2:11:00 PM
>
> "cehrenre" wrote:
>
> > 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date and time calculations =?Utf-8?B?UGFtbXk=?= Microsoft Excel Misc 1 11th Jul 2007 01:54 PM
Removing time from date/time to do date calculations =?Utf-8?B?SmFtaWUgUm9iZXJ0cw==?= Microsoft Access Queries 1 12th Oct 2004 06:58 PM
Date and Time Calculations =?Utf-8?B?bWF0aWxkYQ==?= Microsoft Excel Misc 1 22nd Jan 2004 04:43 PM
Date-Time Calculations April Durett Microsoft Excel Worksheet Functions 1 19th Aug 2003 02:08 AM
Re: Time and Date Calculations Norman Harker Microsoft Excel Worksheet Functions 0 25th Jul 2003 04:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:45 AM.