![]() |
Date Time Calculations - Need Some Direction
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. |
Date Time Calculations - Need Some Direction
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. |
Date Time Calculations - Need Some Direction
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. |
All times are GMT +1. The time now is 05:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com