|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
Calculate time worked.
I wonder if someone could help me find a way of calculating the time worked by an employee using military time…
I have a form with three (3) text boxes and a command button. The first text box “TxtStartTime”, will contain a start time entered by the user in military time, for ex: 0800, 1300, 2330, etc. The second text box “TxtEndTime”, will contain an end time also entered by the user in military time. When the user clicks on the command button “CmdTotal”, I would like to display the total work time in the third text box “TxtTotal”. If the user enters a start time of 0800 and an end time of 1300, then the total time should read 5.00 to indicate that the time worked is 5 hours and zero minutes. If the user enters a start time of 1300 and an end time of 1730, then the total time should read 4.50 to indicate that the time worked is 4 and one half hour. It should not read 4.30. Also, if the user enters a start time of 2300 (11:00 pm) and an end time of 0700 (7:00 am), then the total time should read 8:00 hours worked. Some more examples are:- 0900 to 1315 = 4.25 hours worked. 2200 to 0320 = 5.33 hours worked. 1700 to 1945 = 2.75 hours worked. 1330 to 2005 = 6.58 hours worked. I think these fractions of the hour have something to do with dividing 100 by 60. I do have the correct formula in Excel 97 and it works well. I could send a sample of the Excel spread sheet if that would help someone. Any help would be greatly appreciated, Ron |
|
#2
|
||||
|
||||
|
Hi!
Hmmm, this is really easy. Why don't you separate hours from minutes (simply by digits) go EndTimeHours minus StartTimeHours as well as EndTimeMinutes minus StartTimeMinutes. First, however, make sure that EndTime* is greater then StartTime* and if not, add 60 to EndTimeMinutes respectively 24 to EntTimeHours to make them greater (in case a job takes past midnight, for example). Then print Code:
print "Worked " + StartTimeHours + ":" + StartTimeMinutes + " hours..."; I bet there is a perl module on www.cpan.org for this kind of task. The task should come easy, just the 24ary representation and 60ary representation mixed look difficult. Regards, Atrus. BTW: Why is this a database question, after all? ![]()
__________________
Webmaster - Stefan Meier KG TABAKWAREN - Pfeifen, Premium-Zigarren, ... (_Ger) |
|
#3
|
|||
|
|||
|
wbrooks9926
Quote:
I would like to check out the spread sheet. |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Calculate time worked. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|