Link to home
Start Free TrialLog in
Avatar of Connor Hennessey
Connor Hennessey

asked on

Using Datediff to calculate difference in Seconds between two Infopath fields

Hi,
I am currently using Infopath 2013 which is connected into a SQL server Db, My Infopath Form has three fields:

Start_Time - DateTime
Stop_Time - DateTime
Duration - Integer

I am having trouble referencing these fields in visual studio using VB as it doesn't seem to recognise these as actual fields within the Infopath Form as the Duration field just stays blank with no errors?

Basically i'm looking to do this as an After Change event set on Stop_Time:

Duration = DateDiff("s", Start_Time, Stop_Time)

Open in new window


Very very basic VB knowledge here so any help you can give me will be much appreciated.
Avatar of Norie
Norie

How are you populating the fields?

Have you tried using another event?

Or perhaps, just to make sure the calculation works, using a command button or something similar to run the code you posted?
Avatar of Connor Hennessey

ASKER

Thank you for your reply Norie,

I'm just typing straight into the fields within the form to populate them,

I'm not sure it is the event as I've put a msgbox line in there just to check it was running and that part did work,

I think it may be something to do with how the code knows i'm referencing fields in the actual form, is there something i have to put in to do this?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.