Date Calculation Again, please help

S

Stu Morris

I cant figure this out
Using Jscript
2 date pickers,
one text box returns the difference in days between the 2 dates.

I am having a nightmare with this.
 
S

Sandeep

Hi Stu Morris

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)

If daysElapsed < 3 Then

Msgbox "Date #2 must be at least 3 days in the future!"
XDocument.DOM.selectSingleNode("/my:myFields/my:field3").text = daysElapsed
End If

End Sub

I hope this will help U
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top