# How to compute timestamp difference

**URL:** <https://the.fmsoup.org/t/how-to-compute-timestamp-difference/3630>\
**Category:** Questions\
**Tags:** filemaker\
**Created:** [July 6, 2023, 3:11pm UTC](https://the.fmsoup.org/t/how-to-compute-timestamp-difference/3630 "2023-07-06T15:11:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![marke1415](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@marke1415](https://the.fmsoup.org/u/marke1415)\
**Post date:** [July 6, 2023, 3:11pm UTC](https://the.fmsoup.org/t/how-to-compute-timestamp-difference/3630/1 "2023-07-06T15:11:38Z")

</div>

my requirement is checking the response time of an event:  
example:  
TimeStamp1- 7/6/2023 1:01:10 AM  
TimeStamp2- 7/6/2023 1:15:00 AM

response result should be 00:13:50

i have created a custom function. I am not quite confident on the result. am i doing it right?

is there a simplier function in finding the result

Let([  
$startTime = GetAsTime(TimeStamp1);  
$endTime = GetAsTime(TimeStamp2);  
$timeDiff = GetAsTimestamp($startTime) - GetAsTimestamp( $endTime);  
$hours = Floor($timeDiff / 3600);  
$minutes = Mod(Floor($timeDiff / 60); 60);  
$seconds = Mod($timeDiff; 60);  
$formattedTime = Right("0" & $hours; 2) & ":" & Right("0" & $minutes; 2) & ":" & Right("0" & $seconds; 2)  
];  
$formattedTime  
)

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [July 6, 2023, 4:22pm UTC](https://the.fmsoup.org/t/how-to-compute-timestamp-difference/3630/2 "2023-07-06T16:22:32Z")

</div>

I might start with something like the following, and then adapt if I see shortcomings once I start to test it:

`GetAsTime( Timestamp2 - Timestamp1 )`

I'll note that the above requires that the both of inputs are timestamp data type, and not, for example, strings.

---

<div class="post-metadata">

**Author:** ![marke1415](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@marke1415](https://the.fmsoup.org/u/marke1415)\
**Post date:** [July 6, 2023, 4:42pm UTC](https://the.fmsoup.org/t/how-to-compute-timestamp-difference/3630/3 "2023-07-06T16:42:10Z")

</div>

> [@steve\_ssh](#):
>
> GetAsTime( Timestamp2 - Timestamp1 )

i think the result should be around 00:14:59  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/6/653615f902e07e555121fa1de26631e37c7b7fed.png)

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [July 6, 2023, 4:50pm UTC](https://the.fmsoup.org/t/how-to-compute-timestamp-difference/3630/4 "2023-07-06T16:50:13Z")

</div>

Those are not timestamps that you are supplying as inputs; those are literal strings.

Try creating two timestamp fields in a record, and populate them with timestamp data, and then feed those fields into the calculation expression. Once the inputs are actual timestamps, the distinction between feeding in timestamps and literal strings will hopefully be a little more clear.

---

<div class="post-metadata">

**Author:** ![marke1415](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@marke1415](https://the.fmsoup.org/u/marke1415)\
**Post date:** [July 6, 2023, 5:07pm UTC](https://the.fmsoup.org/t/how-to-compute-timestamp-difference/3630/5 "2023-07-06T17:07:35Z")

</div>

you are right sir Steve

![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/d/df7753dcbae340f3090ea9338ec1c46815ae3a87.png)

now i realized that my problem is my a field in my table

thanks a lot

---

<div class="post-metadata">

**Author:** ![tonywhitelive](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/tonywhitelive/32/208_2.png) [@tonywhitelive](https://the.fmsoup.org/u/tonywhitelive)\
**Post date:** [July 9, 2023, 2:19am UTC](https://the.fmsoup.org/t/how-to-compute-timestamp-difference/3630/6 "2023-07-09T02:19:39Z")

</div>

There is a relevant post on the [Claris Engineering Blog](https://support.claris.com/s/article/Claris-Engineering-Blog?language=en_US)

- [Working with data types in fields and comparisons](https://support.claris.com/s/answerview?anum=000036481&language=en_US)

...that is worth looking at.

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [July 9, 2023, 7:23am UTC](https://the.fmsoup.org/t/how-to-compute-timestamp-difference/3630/7 "2023-07-09T07:23:41Z")

</div>

> [@tonywhitelive](#):
>
> Working with data types in fields and comparisons

Great article. Thank you @tonywhitelive
