Datediff ? - InfoPath Dev
in

InfoPath Dev

Datediff ?

Last post 02-12-2006 08:52 AM by rg66. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-11-2006 09:10 AM

    • rg66
    • Not Ranked
    • Joined on 02-11-2006
    • Austria
    • Posts 4

    Datediff ?

    Hello,

    I have two date fields which are called date_from and date_to. I want to calculate the datediff from these two fields.

    WHat I need to know is:

    1. How do I read the entry from both fields in jscipt or vbscribt?
    2. Make the calculation, is Datediff available om both script level?
    3. Return/write the result in another field within the form

    Can some one help or direct me?

    Best regards,

    Robert
  • 02-11-2006 10:42 AM In reply to

    Check out this awesome tutorial:

    http://enterprise-solutions.swits.net/infopath/adding-time-calculating-differences.htm

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 02-12-2006 02:00 AM In reply to

    • rg66
    • Not Ranked
    • Joined on 02-11-2006
    • Austria
    • Posts 4
    Matt,

    thank you!

    But I am trying to get the basic first and I am struggling here.

    Can you recomment a jscript book in correlation with infopath which explains how to use jscript in infopath.

    I am currently trying to make a OnAfterChange Procedure and what I trying to do is read an entry from a textfield and write it in a different one.

    I am getting kind of frustrated as I have search google now and I even have a book from Microsoft, which has helped me to get started but now I need to write a script and I have no idea how to do that. The documentation is really bad, I have to say.

    Any help?

    Robert
  • 02-12-2006 04:44 AM In reply to

    • sandeep
    • Not Ranked
    • Joined on 11-15-2005
    • India
    • Posts 7
    Hi rg66

    Try this VBscript code

    Dim date_from
    Dim date_to
    Dim dt1Val
    Dim dt2Val
    Dim daysElapsed

    Set date_from = XDocument.DOM.selectSingleNode("/my:myFields/my:date_from")
    Set date_to = XDocument.DOM.selectSingleNode("/my:myFields/my:date_to")

    dt1Val = CDate(date_from.Text)
    dt2Val = CDate(date_to.Text)

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

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

    Thanks


    Sandeep
    InfoPath Dev India
  • 02-12-2006 08:46 AM In reply to

    • rg66
    • Not Ranked
    • Joined on 02-11-2006
    • Austria
    • Posts 4
    sandeep,

    thank you for the code script.

    Just one question: Do I have to place this in the script.js file? Or is there a different place I have to use?

    Robert
  • 02-12-2006 08:52 AM In reply to

    • rg66
    • Not Ranked
    • Joined on 02-11-2006
    • Austria
    • Posts 4
    Just found out what I was missing!

    I started the form and the editor in JScript and not as VBScript. So I will redo the form in VBScript.

    Will test your script out then. Thank you!

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