How to perform subtract operation on textbox with time data type in Infopath forms 2007? - InfoPath Dev Sign in | Join | Help in General InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » General » How to perform subtract operation on textbox with time data type in Infopath forms 2007? How to perform subtract operation on textbox with time data type in Infopath forms 2007? Last post 11-07-2013 10:01 AM by missieyohko. 8 replies. Page 1 of 1 (9 items) Sort Posts: Oldest to newest Newest to oldest Previous Next 03-01-2011 06:11 AM chintan.desai Joined on 10-07-2010 Posts 84 How to perform subtract operation on textbox with time data type in Infopath forms 2007? Reply Contact Hi Folks, I am having 2 text box - Time1 & Time2 with time data type (HH:MM 24hrs format). I need to do subtract operation between Time2 and Time1. Example: Time2:19:30 & Time1:19:00. So, Time2 - Time1. Result: 00:30. Please guide. Thanks. Chintan Thanks,Chintan 03-02-2011 03:28 AM In reply to ErnestoM Joined on 08-27-2007 Posts 3,320 Re: How to perform subtract operation on textbox with time data type in Infopath forms 2007? Mark as Not AnswerMark as Answer... Reply Contact Hi Chintan,You can do this via custom code, or use the DateDiff command in qRules. The documentation included in the trial contains an example of DateDiff! Good luck. Ernesto MachadoQdabra® Software/ InfoPathDev.comThe InfoPath Experts – Streamline data gathering to turn process into knowledge.™ 03-02-2011 03:31 AM In reply to ErnestoM Joined on 08-27-2007 Posts 3,320 Re: How to perform subtract operation on textbox with time data type in Infopath forms 2007? Mark as Not AnswerMark as Answer... Reply Contact Hi Chintan,qRules does this via the DateDiff command, and in fact there is an example in the documentation included in the trial.The other option is to write custom code.Good luck! Ernesto MachadoQdabra® Software/ InfoPathDev.comThe InfoPath Experts – Streamline data gathering to turn process into knowledge.™ 03-02-2011 08:11 AM In reply to Greg Collins Joined on 08-08-2006 Posts 2,126 Re: How to perform subtract operation on textbox with time data type in Infopath forms 2007? Mark as Not AnswerMark as Answer... Reply Contact This can be done using a complicated default value formula:concat(substring(100 + number(concat("0", substring(../my:Time2, 1, 2))) - number(concat("0", substring(../my:Time1, 1, 2))), 2, 2), ":", substring(100 + number(concat("0", substring(../my:Time2, 4, 2))) - number(concat("0", substring(../my:Time1, 4, 2))), 2, 2), ":", substring(100 + number(concat("0", substring(../my:Time2, 7, 2))) - number(concat("0", substring(../my:Time1, 7, 2))), 2, 2))This assumes that Time2 is always intended to be greater than Time1. It will work if both Time1 and Time2 are blank, or if only Time2 is blank. Please Visit:BraintroveGreg's Paintings 03-03-2011 11:27 PM In reply to chintan.desai Joined on 10-07-2010 Posts 84 Re: How to perform subtract operation on textbox with time data type in Infopath forms 2007? Mark as Not AnswerMark as Answer... Reply Contact Thx Greg, Your given code was very useful. It satisfy my requirement. Thanks,Chintan 04-19-2011 03:45 PM In reply to Greg Collins Joined on 08-08-2006 Posts 2,126 Re: How to perform subtract operation on textbox with time data type in Infopath forms 2007? Mark as Not AnswerMark as Answer... Reply Contact Glad to help Please Visit:BraintroveGreg's Paintings 04-20-2011 06:27 AM In reply to tafavorite Joined on 02-01-2011 Posts 65 Re: How to perform subtract operation on textbox with time data type in Infopath forms 2007? Mark as Not AnswerMark as Answer... Reply Contact I have the same situation, just that I am trying to verify the time against an entry field. Here is what I have: Total hrs (10.0) Start (7:00) End (17:00) What I would like to do is make sure that when the user goes to enter the end time, that if verfies that (End - Start) = Total hrs. This way they will be notified after entry that they need to enter the correct time. 04-20-2011 01:51 PM In reply to qwerty Joined on 02-01-2011 Posts 60 Re: How to perform subtract operation on textbox with time data type in Infopath forms 2007? Mark as Not AnswerMark as Answer... Reply Contact Hi there, If you have IP2007 + you can use the built in addSeconds(time, secondsToAdd) function. 10 hrs * 60 min * 60 sec = 36000 seconds, so the condition is If endTime Is Not Equal To addSeconds(startTime, 36000). If you have IP2003, you can hook up something similar with the formula above ^. Hope this helps! 11-07-2013 10:01 AM In reply to missieyohko Joined on 07-15-2013 Posts 30 Re: How to perform subtract operation on textbox with time data type in Infopath forms 2007? Mark as Not AnswerMark as Answer... Reply Contact Greg Collins:This can be done using a complicated default value formula:concat(substring(100 + number(concat("0", substring(../my:Time2, 1, 2))) - number(concat("0", substring(../my:Time1, 1, 2))), 2, 2), ":", substring(100 + number(concat("0", substring(../my:Time2, 4, 2))) - number(concat("0", substring(../my:Time1, 4, 2))), 2, 2), ":", substring(100 + number(concat("0", substring(../my:Time2, 7, 2))) - number(concat("0", substring(../my:Time1, 7, 2))), 2, 2))This assumes that Time2 is always intended to be greater than Time1. It will work if both Time1 and Time2 are blank, or if only Time2 is blank.I'm sorry to revive a dead thread but I'm curious about some of this logic... When I want to understand long equations I write them out step by step... So I hope this makes sense and if I've made an error please let me know where...STARTTIME 12:00:00ENDTIME 13:00:00substring(100 + number(concat("0", substring(../my:EndTime, 1, 2))) - number(concat("0", substring(../my:StartTime, 1, 2))), 2, 2)substring(100 + number(concat("0", "03" )) - number(concat("0", "02" )), 2, 2)substring(100 + number("003" ) - number("002" )), 2, 2)substring(100 + 3 - 2 ), 2, 2)substring(101 ), 2, 2)"01"What was the point of concatenating "0" in the 3rd step? Page 1 of 1 (9 items) Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
Hi Chintan,
You can do this via custom code, or use the DateDiff command in qRules. The documentation included in the trial contains an example of DateDiff!
Good luck.
qRules does this via the DateDiff command, and in fact there is an example in the documentation included in the trial.
The other option is to write custom code.
Good luck!
This can be done using a complicated default value formula:
This assumes that Time2 is always intended to be greater than Time1. It will work if both Time1 and Time2 are blank, or if only Time2 is blank.
Glad to help
I have the same situation, just that I am trying to verify the time against an entry field. Here is what I have:
Total hrs (10.0)
Start (7:00)
End (17:00)
What I would like to do is make sure that when the user goes to enter the end time, that if verfies that (End - Start) = Total hrs. This way they will be notified after entry that they need to enter the correct time.
Greg Collins:This can be done using a complicated default value formula:concat(substring(100 + number(concat("0", substring(../my:Time2, 1, 2))) - number(concat("0", substring(../my:Time1, 1, 2))), 2, 2), ":", substring(100 + number(concat("0", substring(../my:Time2, 4, 2))) - number(concat("0", substring(../my:Time1, 4, 2))), 2, 2), ":", substring(100 + number(concat("0", substring(../my:Time2, 7, 2))) - number(concat("0", substring(../my:Time1, 7, 2))), 2, 2))This assumes that Time2 is always intended to be greater than Time1. It will work if both Time1 and Time2 are blank, or if only Time2 is blank.
I'm sorry to revive a dead thread but I'm curious about some of this logic... When I want to understand long equations I write them out step by step... So I hope this makes sense and if I've made an error please let me know where...
STARTTIME 12:00:00ENDTIME 13:00:00substring(100 + number(concat("0", substring(../my:EndTime, 1, 2))) - number(concat("0", substring(../my:StartTime, 1, 2))), 2, 2)substring(100 + number(concat("0", "03" )) - number(concat("0", "02" )), 2, 2)substring(100 + number("003" ) - number("002" )), 2, 2)substring(100 + 3 - 2 ), 2, 2)substring(101 ), 2, 2)"01"
What was the point of concatenating "0" in the 3rd step?