# Automatic time calculation

**URL:** <https://forum.dimagi.com/t/automatic-time-calculation/1704>\
**Category:** Users\
**Created:** [April 13, 2014, 2:33pm UTC](https://forum.dimagi.com/t/automatic-time-calculation/1704 "2014-04-13T14:33:23Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![Clayton\_Sims](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/clayton_sims/32/496_2.png) [@Clayton\_Sims](https://forum.dimagi.com/u/Clayton_Sims)\
**Post date:** [May 20, 2019, 11:15pm UTC](https://forum.dimagi.com/t/automatic-time-calculation/1704/11 "2019-05-20T23:15:35Z")

</div>

The other option would be to manipulate the times using the [substring-before() and substring-after() functions](https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-substring-before) to make your own integer representations of the times that are entered

IE:

int(substring-before(#form/timestart, ":")) \* 60 + int(substring-after(#form/timestart, ":"))

would in theory produce a number of minutes that could be subtracted from a similar calculation for a "time of end", but that wouldn't properly calculate for times that 'wrap around' (IE: 11:30pm -\> 1:30am) or other edge cases.

-Clayton

---

_[View the full topic](https://forum.dimagi.com/t/automatic-time-calculation/1704)._
