# Time duration field format

**URL:** <https://speciforum.org/t/time-duration-field-format/2647>\
**Category:** Get Help\
**Created:** [June 24, 2025, 7:46pm UTC](https://speciforum.org/t/time-duration-field-format/2647 "2025-06-24T19:46:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marion](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@Marion](https://speciforum.org/u/Marion)\
**Post date:** [June 24, 2025, 7:46pm UTC](https://speciforum.org/t/time-duration-field-format/2647/1 "2025-06-24T19:46:46Z")

</div>

I’d like to create a format for entering time duration information under the form hh:mm:ss (hour:minute:second). The aim would be to be able to integrate the duration of a recording, its start and also its end. This would be useful for our ‘Animal sound archive’ collection.

I’ve managed to create a format in the form ##:##:## but I’d like it to default to 00:00:00 and I’d also like the first digit to be limited to numbers 1 to 24, and the second and third to be limited to numbers 1 to 60.

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/specifysoftware/original/2X/6/66235bbb2e6d4a5029d00780f249ef5eefeff276.png)  
 ![image](https://canada1.discourse-cdn.com/flex029/uploads/specifysoftware/original/2X/e/e2d4d8b0804e7c595c7830862bbf7dbfa04d3c3b.png)

Does this have anything to do with ?

And also, does Specify have any other way of integrating durations?

Thanks

---

<div class="post-metadata">

**Author:** ![Grant](https://yyz1.discourse-cdn.com/flex029/user_avatar/speciforum.org/grant/32/4255_2.png) [@Grant](https://speciforum.org/u/Grant)\
**Post date:** [June 24, 2025, 8:13pm UTC](https://speciforum.org/t/time-duration-field-format/2647/2 "2025-06-24T20:13:02Z")

</div>

Hi @Marion,

Thanks for your question! You were in the right place when you asked about this problem, as a [regular expression field format](https://speciforum.org/t/catalog-number-regular-expression-formatter-set-up-in-specify-7/766) is the only way to handle this as you describe.

In the **Field Formatter** app resource (`UIFormatters`, you can create one if none exists), you need to add the following format:

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/specifysoftware/original/2X/4/4fe4c527cf3ddc65b8a314a1e164caed95bc78c3.jpeg)

> [!warning]  
> Make sure to replace the `class` and `fieldname` with the name of the table (e.g. `CollectingEvent`) and the name of the field (e.g. `text5`) in the corresponding spaces below. You can create multiple formats for additional fields if needed.

```xml
  <format
    system="false"
    name="DurationHHMMSS"
    class="edu.ku.brc.specify.datamodel.CollectingEvent" 
    fieldname="text5">
  <!-- Enforce exactly 8 characters: hh:mm:ss -->
    <field
      type="regex"
      size="8"
      value="(0[0-9]|1[0-9]|2[0-4]):([0-5][0-9]):([0-5][0-9])"
      pattern="00:00:00" />
  </format>

```

In the **Schema Config** , you will need to assign the field you want to assign a format to to that (e.g. `DurationHHMMSS`):

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/specifysoftware/original/2X/6/6a884957bdaeebce70b9d0834dcc14ccf8829f44.jpeg)

In your **View Definition XML** , you just need to make sure the field you want to format is visible _and_ this is where you would want to set the default for the field (e.g. `00:00:00`):

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/specifysoftware/original/2X/8/84efc8db09fed61d76a0d78fa38461daa7d9d99b.jpeg)

```xml
<row>
	<cell type="label" labelfor="timeDuration"/>
	<cell type="field" id="timeDuration" name="text5" uitype="text" default="00:00:00"/>
</row>

```

Now you have a working timestamp field with the restrictions you described (\*slight adjustment with “1 to 59” instead of “1 to 60”)!

Invalid (`25` \> `24`, restricted by the format):

 ![BadValue](https://canada1.discourse-cdn.com/flex029/uploads/specifysoftware/original/2X/8/80d3a561114993ca2937dd8d31f7040bc6a16e20.png)

Valid (`23:59:20` matches the format)

 ![Valid value](https://canada1.discourse-cdn.com/flex029/uploads/specifysoftware/original/2X/6/6d3527122a6ff0021359df99c3b978729f025a0e.png)

* * *

There are no other specific integrations for durations in Specify, but I am interested to hear what you have in mind!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex029/uploads/specifysoftware/original/2X/1/18a843c97bc32b40e8ad0e035755bc88ffaacaf7.svg) [@system](https://speciforum.org/u/system)\
**Post date:** [July 1, 2025, 8:13pm UTC](https://speciforum.org/t/time-duration-field-format/2647/3 "2025-07-01T20:13:21Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
