Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

Duration API in h:mm and not seconds

1221 2
cancel
Showing results for 
Search instead for 
Did you mean: 
silaswrn
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi there. I have created a time tracking app and used Airtable as backend. While it works perfectly for all get API requests I have troubles with post requests.

Users need to fill in a duration that they have worked. While everything else works absolutely fine I can't work out how I can create an API Post request where the user can input the duration using h:mm format and not seconds. I can work around it in Airtable using the formula but it is not practical to have App users type in their work time in seconds.

Is there a way to create a working post request? I am slowly starting to loose hope in Airtable. 

thx in advance

2 Replies 2
kuovonne
18 - Pluto
18 - Pluto

Are you using the Web API? Have you tried setting the typecast parameter to true? 

Another option is to have users enter their data in h:mm format in a text field and then use a formula field to convert to numeric format (if necessary).

silaswrn
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi. Yes, I think I use Web API. Typecast sadly doesn't make a difference in my case. It is set to true via JSON:

{
"typecast": true
}

Currently my users input their working hours in a text field in my app. To calculate with their entries I then convert them into duration fields via "VALUE({field name})".

However in the end I want to present the result of my calculation in the app. Doing so it presents the result in seconds. If I the convert it into a number it always gives me a number with endless decimal places (ex: 4.16666...) which is not practical for my app. Currently I work around it with a formula field that rounds the number (4.16666... -> 4).

However I would need an exact result. So I would need an option to either only send 2 decimal places via API or a way to convert a duration into a string and then send the string via API.