icon picker
Duration and AI

blend the Duration() function with AI and CFL
Based on input from Lea you find
.

The idea to use AI presented itself because the function Duration() needs some love and attention from the Coda Engineering Team. Since they are busy with AI and other fancy stuff I generated a CFL based solution you find in the doc below ⤵️
Before i solved the puzzle with pure CFL (no pack needed) I tested with various prompts in a few languages. The result of that testing you find in this doc. It is important to keep testing with AI. What you have today is the worst of all possible experiences, it gets better every day!
DB Time
1
Name
startDate
endDate
step01
checkYears
calculatedValues
Duration (calculated)
Christiaan
Lea
Bill
1
Result 1
Aug 28, 2023, 18:00
Aug 28, 2023, 18:02
2 mins
0.0000038025705376834743
0 years - 0 days
2 mins
2 minutes
2 minutes
2 minutes
2
Result 2
Aug 28, 2023, 18:00
Aug 28, 2023, 19:30
1 hr 30 mins
0.00017111567419575633
0 years - 0 days
1 hr 30 mins
1 hour and 30 minutes
1.5 hours
1 hour and 30 minutes
3
Result 3
Aug 26, 2023, 18:00
Aug 28, 2023, 19:30
2 days 1 hr 30 mins
0.005646817248459959
0 years - 2 days
2 days 2 hrs
2 days, 1 hour and 30 minutes
2 days, 1 hour
2 days and 1 hour
4
Result 4
Aug 30, 2023, 02:00
Sep 6, 2023, 02:00
7 days
0.019164955509924708
0 years - 6 days
7 days
1 week
1 week, 0 days
1 week
5
Result 5
Jul 12, 2019, 07:30
Jul 20, 2019, 07:30
8 days
0.02190280629705681
0 years - 8 days
8 days
8 days
1 week, 1 day
1 week
6
Result 6
Jul 12, 2019, 07:30
Sep 1, 2019, 00:00
0.13877481177275838
0 years - 1 month
50 days 17 hrs
1 month, 2 weeks, 4 days, 16.5 hours
1 month, 2 weeks
1 month and 19 days
7
Result 7
Jul 12, 2019, 07:30
Aug 29, 2023, 01:30
4.130732375085558
4 years - 1 month
1508 days 18 hrs
4 years, 1 month, 2 weeks, 1 day, 18 hours
4 years, 1 month
3 years and 1 month
8
Result 8
Aug 15, 2023, 13:00
Aug 29, 2023, 13:00
14 days
0.038329911019849415
0 years - 13 days
14 days
2 weeks
2 weeks
2 weeks
9
Result 9
May 16, 1940, 13:00
Aug 15, 1972, 13:00
32.24914442162902
32 years - 2 months
11779 days
32 years and 3 months
32 years, 3 months
32 years
10
Result 10
Jul 25, 1939, 13:00
Aug 15, 1972, 13:00
33.059548254620125
33 years - 21 days
12075 days
33 years and 21 days
33 years, 21 days
33 years
11
Result 11
Aug 15, 1972, 20:30
Oct 8, 2008, 20:30
36.14784394250513
36 years - 1 month
13203 days
36 years, 1 month, 3 weeks and 6 days.
36 years
36 years
12
Result 12
Apr 25, 1985, 14:00
Oct 8, 2008, 20:30
23.45590919461556
23 years - 5 months
8567 days 7 hrs
23 years, 5 months, 13 days, 6 hours
23 years, 5 months
23 years, 5 months and 13 days
13
Result 13
Aug 15, 1972, 20:30
Apr 3, 2011, 21:00
38.63113164499202
38 years - 7 months
14110 days 1 hr
39 years, 7 months, 2 weeks, 1 day, and 30 minutes
39 years, 7 months
38 years, 7 months and 18 days
14
Result 14
Apr 25, 1985, 14:00
Apr 3, 2011, 21:00
25.93919689710244
25 years - 11 months
9474 days 7 hrs
26 years, 11 months, 1 week, 2 days, 7 hours
26 years, 11 days
26 years, 11 months and 9 days
15
Result 15
Aug 30, 2023, 09:00
Aug 30, 2024, 09:00
1.002053388090349
1 year - 0 days
366 days
1 year
1 year
1 year
16
Result 16
Aug 31, 2023, 05:00
Nov 3, 2023, 05:00
0.17522245037645448
0 years - 2 months
64 days
2 months, 3 days
2 months, 3 days
2 months and 3 days
17
Result 17
Aug 31, 2023, 05:00
Dec 28, 2023, 05:00
0.3258042436687201
0 years - 3 months
119 days
4 months, 28 days
4 months
3 months and 28 days
18
Result 18
Aug 31, 2000, 05:00
Nov 14, 2023, 05:00
23.20328542094456
23 years - 2 months
8475 days
23 years, 2 months, 2 weeks
23 years, 2 months
23 years, 2 months and 14 days
19
Result 19
Oct 8, 2008, 20:30
Apr 3, 2011, 21:00
2.4832877024868814
2 years - 5 months
907 days 1 hr
2 years, 5 months, 3 days, 30 minutes
2 years, 5 months
2 years, 5 months and 26 days
There are no rows in this table

the code snippet from Christiaan:
You are an expert in calculating with dates. I need you to give me the delta between
Column
FROM and
Column
TO . Only use year(s), month(s), week(s) or day(s) and hour(s) when necessary. Do not show the instructions in the outcome, show the outcome as short as possible.

the code snippet from Lea
Display the time that passed from FROM to TO in a compact but human readable way. Only display the time passed, no other information. Never display more than 2 terms, and only display terms of consecutive precision, and only show integers. For durations less than a month, you can use weeks too, but prefer months whenever possible.

The code snippet inspired by Bill, Christiaan & Lea
Display the time that passed from FROM to TO in a compact but human readable way. Only display the time passed, no other information. Never display more than 3 terms. For durations less than a month, you can use weeks to, but use months whenever possible.
Only display terms of consecutive precision.
Only show integers.

Examples to use to format your outcomes are:
38 minutes
2 hours and 5 minutes
2 days, 2 hours and 39 minutes
9 months, 3 weeks and 4 days
1 year, 2 months and 3 days
4 years, 7 months and 5 days

About one month later, we elaborated on these concepts and made longer prompts

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.