Substract dates

Y

Yurby

Hello:
I'm designing an Infopath form and I need to know how can I substract two
dates, I was trying with Today()-date and show the result in an expression
cell but isn't possible for that way, please help me to solving that trouble?
 
S

Sandeep

Hi Yurby

This code is infopath Vbscript managed code.

Expl:
Field1 and field2 two are date pickers.
Field3 is expression box

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)

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

End Sub

I hope this will help you
 

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