Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
How do i calculate time ; hours worked ? I am trying to find a field code
formula in a Word table and then to minus that by 0.30? I have designed a Timesheet but want to calculate daily hours then minus it by lunch break. Can anyone help? I have seen time calculations but i can't find time as in hours worked. |
#2
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
Hi kimla10,
Although it can be done in Word, Excel is a far better tool for this. And, in Word, a macro is probably going to give you a better solution than a field code. Here's some code recently posted recently by Jay Freedman, another Microsoft Word MVP: Sub demo() Dim startTime As Date, endTime As Date Dim diffHr As Long, diffMin As Long startTime = CDate("8:00 am") endTime = CDate("12:35 pm") diffMin = Abs(DateDiff("n", startTime, endTime)) diffHr = Int(diffMin / 60) ' truncated to whole hours diffMin = diffMin Mod 60 ' remaining minutes MsgBox diffHr & ":" & diffMin End Sub To make this work in your table, you'd need to get the startTime & endTime from formfields with their properties set to run the macro on exit, then output the result to another field instead of to the message box. Having said all the above, if you *really* want to go down the field code route, you can how to do this and just about everything else you might want to do with dates in Word, check out my Date Calc 'tutorial', at: http://www.wopr.com/cgi-bin/w3t/show...?Number=249902 or http://www.gmayor.com/downloads.htm#Third_party Cheers -- macropod [MVP - Microsoft Word] ------------------------- "kimla10" wrote in message ... How do i calculate time ; hours worked ? I am trying to find a field code formula in a Word table and then to minus that by 0.30? I have designed a Timesheet but want to calculate daily hours then minus it by lunch break. Can anyone help? I have seen time calculations but i can't find time as in hours worked. |
#3
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]() Excel is better equipped for this. If you want it in Word, eg if you need to make a weekly report, you can link the Excel table to the word document so it automatically updates in Word once changed in Excel. macropod;2433439 Wrote: Hi kimla10, Although it can be done in Word, Excel is a far better tool for this. And, in Word, a macro is probably going to give you a better solution than a field code. Here's some code recently posted recently by Jay Freedman, another Microsoft Word MVP: Sub demo() Dim startTime As Date, endTime As Date Dim diffHr As Long, diffMin As Long startTime = CDate("8:00 am") endTime = CDate("12:35 pm") diffMin = Abs(DateDiff("n", startTime, endTime)) diffHr = Int(diffMin / 60) ' truncated to whole hours diffMin = diffMin Mod 60 ' remaining minutes MsgBox diffHr & ":" & diffMin End Sub To make this work in your table, you'd need to get the startTime & endTime from formfields with their properties set to run the macro on exit, then output the result to another field instead of to the message box. Having said all the above, if you *really* want to go down the field code route, you can how to do this and just about everything else you might want to do with dates in Word, check out my Date Calc 'tutorial', at: http://www.wopr.com/cgi-bin/w3t/show...?Number=249902 or http://www.gmayor.com/downloads.htm#Third_party Cheers -- macropod [MVP - Microsoft Word] ------------------------- "kimla10" wrote in message ...- How do i calculate time ; hours worked ? I am trying to find a field code formula in a Word table and then to minus that by 0.30? I have designed a Timesheet but want to calculate daily hours then minus it by lunch break. Can anyone help? I have seen time calculations but i can't find time as in hours worked. - -- Henk57 |
#4
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
Thanks very very much. I did think that it was better in Excel but i didn't
know i could link the two. Thanks a bunch. I am very grateful for the info. Kimla10 "Henk57" wrote: Excel is better equipped for this. If you want it in Word, eg if you need to make a weekly report, you can link the Excel table to the word document so it automatically updates in Word once changed in Excel. macropod;2433439 Wrote: Hi kimla10, Although it can be done in Word, Excel is a far better tool for this. And, in Word, a macro is probably going to give you a better solution than a field code. Here's some code recently posted recently by Jay Freedman, another Microsoft Word MVP: Sub demo() Dim startTime As Date, endTime As Date Dim diffHr As Long, diffMin As Long startTime = CDate("8:00 am") endTime = CDate("12:35 pm") diffMin = Abs(DateDiff("n", startTime, endTime)) diffHr = Int(diffMin / 60) ' truncated to whole hours diffMin = diffMin Mod 60 ' remaining minutes MsgBox diffHr & ":" & diffMin End Sub To make this work in your table, you'd need to get the startTime & endTime from formfields with their properties set to run the macro on exit, then output the result to another field instead of to the message box. Having said all the above, if you *really* want to go down the field code route, you can how to do this and just about everything else you might want to do with dates in Word, check out my Date Calc 'tutorial', at: http://www.wopr.com/cgi-bin/w3t/show...?Number=249902 or http://www.gmayor.com/downloads.htm#Third_party Cheers -- macropod [MVP - Microsoft Word] ------------------------- "kimla10" wrote in message ...- How do i calculate time ; hours worked ? I am trying to find a field code formula in a Word table and then to minus that by 0.30? I have designed a Timesheet but want to calculate daily hours then minus it by lunch break. Can anyone help? I have seen time calculations but i can't find time as in hours worked. - -- Henk57 |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can you recover an unsaved document 24 hours later? | Microsoft Word Help | |||
Working with formulas in Word tables - calculating time on scene. | Tables | |||
convert time to hours in Word table | Tables | |||
Word practically shuts down after 10 hours | Microsoft Word Help |