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 / September 2004

Tip: Looking for answers? Try searching our database.

Guess nobody know how to do this one.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
afiveo - 22 Sep 2004 20:59 GMT
I am trying to make a time sheet for the people that work under me.  What I
would like to do is have them put in the starting date and have the computer
calulate the ending date.  also put the day of the week and the date in the
boxes next to where they are to put in their time.
Josh Bertsch [MSFT] - 22 Sep 2004 21:30 GMT
This has to be done completely in code as there is no way to do a date diff
through the UI.

Here was a suggestion listed a while ago:

Date diff:

Mathmatical operations involving two time values don't make much sense
IMHO.  Usually it's a time +/- an offset like X hours or something.
But, here goes:

var dom = XDocument.DOM;
var t1 = dom.selectSingleNode("my:myFields/my:time1").nodeTypedValue;
var t2 = dom.selectSingleNode("my:myFields/my:time2").nodeTypedValue;
var t = null;

if (t1.match(/T(\d\d):(\d\d):(\d\d)/))
  t1 = Number(RegExp.$1)*3600 + Number(RegExp.$2)*60 +
Number(RegExp.$3);
else
  XDocument.UI.Alert("Time 1 is invalid.");

if (t2.match(/T(\d\d):(\d\d):(\d\d)/))
  t2 = Number(RegExp.$1)*3600 + Number(RegExp.$2)*60 +
Number(RegExp.$3);
else
  XDocument.UI.Alert("Time 2 is invalid.");

t = t1 + t2;

var h = Math.floor(t / 3600);
var m = Math.floor(t % 3600 / 60);
var s = t % 60;

t = String(h + ":" + m + ":" + s).replace(/\b(\d)\b/g, "0$1");

XDocument.UI.Alert(t);

--josh bertsch

> I am trying to make a time sheet for the people that work under me.  What I
> would like to do is have them put in the starting date and have the computer
> calulate the ending date.  also put the day of the week and the date in the
> boxes next to where they are to put in their time.
 
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.