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 / March 2006

Tip: Looking for answers? Try searching our database.

Yet another Date Picker Calculation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Larry Cook - 14 Mar 2006 03:07 GMT
I have two date pickers and a text field.  One of the Date Pickers is a
Target Date and the second is the Actual Competion Date.  I want a positive
or negative result in days in the third field.  How do I subtract two date
pickers?  I have tried the examples here and have not been able to get it to
work.  I have little programming knowledge.  Thanks in advance, Larry
S.Y.M. Wong-A-Ton - 14 Mar 2006 08:46 GMT
Did you already check out the date and time section on my website
(http://enterprise-solutions.swits.net/infopath/solutions.htm#datetime)? I
have a few solutions listed there that should help you get started. Check out
http://enterprise-solutions.swits.net/infopath/datediff-vbscript-infopath.htm
in particular.
---
S.Y.M. Wong-A-Ton

> I have two date pickers and a text field.  One of the Date Pickers is a
> Target Date and the second is the Actual Competion Date.  I want a positive
> or negative result in days in the third field.  How do I subtract two date
> pickers?  I have tried the examples here and have not been able to get it to
> work.  I have little programming knowledge.  Thanks in advance, Larry
Larry Cook - 15 Mar 2006 01:34 GMT
Yes the "Calculating date and time differences with custom VBScript code" was
very helpful and I got the example to work on my practice form, but when I
entered a end date before a start date I got a zero number.  I need to have a
negative number.  I want to track projects.  A target date and a completion
date.  If a person gets a project done ahead of time they have a positive
number in days.  If they are behind schedule I want it to be a negative
number.  

The second example "Calculating date differences in InfoPath using VBScript
code" was confusing to me.  I was unsure on where to put the code.  You
listed a Function code section and then the code for the ISODateToVBDate
function.  It was unclear to me on how to insert the code into my form.  

                 Thanks for you time,

                     Larry

> Did you already check out the date and time section on my website
> (http://enterprise-solutions.swits.net/infopath/solutions.htm#datetime)? I
[quoted text clipped - 9 lines]
> > pickers?  I have tried the examples here and have not been able to get it to
> > work.  I have little programming knowledge.  Thanks in advance, Larry
S.Y.M. Wong-A-Ton - 15 Mar 2006 08:58 GMT
All solutions posted on the website are examples on how you could get
something done in InfoPath. Needless to say, you need to modify them to suit
your own needs. I can impossibly cater for every InfoPath scenario that there
might be out there. :)

In "Calculating date and time differences with custom VBScript code" you
need to modify the calcTimeInMinutes function to use in your own situation.
And since you  are only dealing with dates, you need to strip out the times.
Change the last line of the function to

calcTimeInMinutes = intDateDiffMin

and remove everything between and including

If intDateDiffMin >= 0 Then
...
End If

and you should be good to go.

The second example "Calculating date differences in InfoPath using VBScript
code" states somewhere in the text just after the ISODateToVBDate function to
"Add the following code to the event handler of a field or button". So you
either need to add a button and put the code in its event handler or add an
OnAfterChange event handler for one of the fields on your form. The
ISODateToVBDate function can go anywhere in the form's code as long as it's
not placed inside another function or event handler.
---
S.Y.M. Wong-A-Ton

> Yes the "Calculating date and time differences with custom VBScript code" was
> very helpful and I got the example to work on my practice form, but when I
[quoted text clipped - 26 lines]
> > > pickers?  I have tried the examples here and have not been able to get it to
> > > work.  I have little programming knowledge.  Thanks in advance, Larry
 
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.