calculate hours worked from two date/time cells

G

Geoff May

I am developing a timesheet and have one cell with start time and one with
finish time. I want a third cell to show hours worked being the difference
between cell two and cell one. I have tried formulas and rules in the third
cell without success. Can you advise please Thanks Geoff may
 
B

Bojana Marjanovic [MSFT]

Hi Geoff,
I'm afraid there's no easy way to do this in Office 2003. You will have to
write some code to perform these calculations.
We are working on improving support for this scenario in our upcoming
release.
-Bojana
 
S

Sandeep

Hi Geoff,

This code is infopath Vbscript managed code.

Expl:
Field1 and field2 two are date pickers.
Field3 is textbox
Past this code

Sub CTRL18_5_OnClick(eventObj)

Dim nodeDate1
Dim nodeDate2
Dim dt1Val
Dim dt2Val
Dim daysElapsed

Set nodeDate1 = XDocument.DOM.selectSingleNode("/my:myFields/my:field1")
Set nodeDate2 = XDocument.DOM.selectSingleNode("/my:myFields/my:field2")

dt1Val = CDate(nodeDate1.Text)
dt2Val = CDate(nodeDate2.Text)

daysElapsed = DateDiff("d", dt1Val, dt2Val)

XDocument.DOM.selectSingleNode("/my:myFields/my:field3").text = daysElapsed
End Sub

I hope this will help U
 

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