Infopath 2003 - InfoPath Dev
in

InfoPath Dev

Infopath 2003

Last post 11-05-2008 06:00 PM by Hilary Stoupa. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 11-05-2008 07:24 AM

    • Scotl
    • Not Ranked
    • Joined on 11-05-2008
    • Posts 4

    Infopath 2003

    I am a newbie, self teaching my self the basics for creating form and codes

     

    What are the codes for days, months, years?

    How can I subtract on day from the current date      Today()

    How can I find the difference between    Today ()  and a date that is entered into a field by a user?

     

    Thanks 

     

  • 11-05-2008 07:39 AM In reply to

    Hi, and welcome!

    I created a 2003 version of a template I made with some samples to get the days, months and years using rules. You can find that here.

    As far as date math, in IP 2003, you'll need to use code for that. Are you using script or managed code?

    Hilary Stoupa

  • 11-05-2008 09:52 AM In reply to

    • Scotl
    • Not Ranked
    • Joined on 11-05-2008
    • Posts 4

    Hilary,

     Thanks for access to the template.

     I will use whatever is best to get the job complete. All the codes go in the Fx section of the formula placement section in InfoPath 2003, correct?

     I was told that several formulas for subtracting dates were not possible until 2007.

     

    Jeff

  • 11-05-2008 11:26 AM In reply to

    Well, if you are using IP 2003 and are not using Visual Studio, you'll need to use JScript or VBScript. Code goes into form events, so you need to add an event to the field or action that should trigger the date calculation. Can you provide some more information about the types of date calculations you need to do?

    Hilary Stoupa

  • 11-05-2008 12:11 PM In reply to

    • Scotl
    • Not Ranked
    • Joined on 11-05-2008
    • Posts 4

     

     

    I am providing a calculation form for my staff. It allows them to find where they stand in a selection process for offices.

    I need to calculate their time of service.

    I am hoping to find a formula where I can take the Current Date      'today()'    when using InfoPath 2003 functions   and subtract a date  in which they would enter in one field.

    I need to take the difference and display the Years and days  

     

     

     

  • 11-05-2008 06:00 PM In reply to

    Okay. First you'll need to set your form's programming language to VBScript. I don't remember exactly where that is in IP2003 -- in 2007, it is under Tools/Form Options/Programming. You can right click the date field your user is entering their start date, and in the context menu, under Programming, select the On After Change event. This will add the event to your form and open the script editor.

    The sample code gets the difference between two dates that are entered in the form and enters the days between the dates in a text box. To do what you need, the script would look more like this:

    Dim start
    Dim startDate
    Dim diff
    Set start = XDocument.DOM.selectSingleNode("/my:myFields/my:field1")

    If start.text = "" Then
       Exit Sub
    End If

    startDate = CDate(start.text)
    diff = DateDiff("d", startDate, Date) XDocument.DOM.selectSingleNode("/my:myFields/my:field2").text = diff

    This VBScript gets the number of days between today and a field (field1) in the form, then returns that value in field2 in the same form. To get years and days, you'll need to divide diff by 365 for the years, and then get the remainder for days.... Hope this helps!

    Hilary Stoupa

Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.