Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / February 2006

Tip: Looking for answers? Try searching our database.

calculate hours worked from two date/time cells

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Geoff May - 10 Jan 2006 22:46 GMT
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
Bojana Marjanovic [MSFT] - 16 Jan 2006 20:54 GMT
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

>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
Sandeep - 06 Feb 2006 08:22 GMT
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

Signature

Sandeep
www.autonomysystems.com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.