Brian Dunning's FileMaker Custom Functions

diffForHumans ( ts )

Convert timestamp difference to human readable text

  Be the first to rate this function Log in to vote

Ángel Martínez Fernández   Ángel Martínez Fernández - Show more from this author
Lesterius Barcelona
https://www.lesterius.es/

Share on Facebook Share on Twitter

  Sample input:
diffForHumans ( "6/5/2020 17:18:03" )
  Sample output:
//Get ( CurrentTimeStamp ) = 6/5/2020 17:30:42
//Result:
12 minute(s) ago

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Just as Carbon docs describes it:
It is easier for humans to read "1 month ago" compared to "30 days ago". This is a common function seen in most date libraries so I thought I would add it here as well.

 

Comments

TA   TA
May 20, 2020
Thanks for the upload,
When It is 8 days ago, it still shows 1 week ago. Same thing from 8 to 13 days, All show 1 week ago. I am doing something wrong?
I even tried it against a time difference for Date of Birth, the difference can be up to a year.
 
Ángel Martínez Fernández   Ángel Martínez Fernández, Lesterius Barcelona
May 20, 2020
Hello TA,
You are doing it right, var “d” The difference in days, and in your case “8” is being divided by “7” inside of var “w” being the result “1,1428571429”, then in the Case() as var “w” is greater than 1, it show the “1 week ago”.
If you want the function to only show the difference up to days. The Case() should be like this:
Case (
d ≥ 1 ; d & " day(s) ";
h ≥ 1 ; h & " hour(s) ";
m ≥ 1 ; m & " minute(s) ";
s & " second(s) "
)
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: