Forum Discussion
I had trouble posting to the end of the thread but here is a corrected and tested version.
var date MyDate = [My Date];
var text Years = ToText(Year(Today())-Year($MyDate) -
If( Month(Today())<Month($MyDate)
or
(Month(Today())=Month($MyDate) and Day(Today())<Day($MyDate)),1,0));
var text Months = If(
Month(Today()) > Month($MyDate), ToText(Month(Today()) - Month($MyDate)),
Month(Today()) = Month($MyDate) and Day(Today()) >= Day($MyDate), ToText(Month(Today()) - Month($MyDate)),
Month(Today()) = Month($MyDate) and Day(Today()) < Day($MyDate), "11",
ToText(12-(Month($MyDate) - Month(Today()))));
var text DaysDisplay = If ( Day(Today()) > Day($MyDate), ToText( Day(Today()) - Day($MyDate) ),
Day(Today()) = Day($MyDate), "0",
Day(Today()) < Day($MyDate), ToText( Day($MyDate)-Day(Today()) ));
var text RawResult=
$Years & " Year" & If ($Years <> "1","s","") & "<br>" &
$Months & " Month" & If($Months<>"1","s", "") & "<br>" &
$DaysDisplay & " Day" & If($DaysDisplay<>"1","s", "");
If(not IsNull($MyDate), $RawResult)
------------------------------
Mark Shnier (Your Quickbase Coach)
mark.shnier@gmail.com
------------------------------
Thanks Mark, this really good and useful code that you provided!
If anyone is looking for a return that is a numeric number, I adjusted Mark's code here:
var date MyDate = [In Service Date];
var text Years = ToText(Year(Today()) - Year($MyDate) -
If(Month(Today()) < Month($MyDate)
or
(Month(Today()) = Month($MyDate) and
Day(Today()) < Day($MyDate)),1,0));
var text Months = If(
Month(Today()) > Month($MyDate), ToText(Month(Today()) - Month($MyDate)),
Month(Today()) = Month($MyDate) and Day(Today()) >= Day($MyDate),
ToText(Month(Today()) - Month($MyDate)),
Month(Today()) = Month($MyDate) and Day(Today()) < Day($MyDate), "11",
ToText(12-(Month($MyDate) - Month(Today()))));
var text RawResult=
$Years & "." & $Months;
If(not IsNull($MyDate), $RawResult)
This is still a Formula Text field but you can create an additional Formula Numeric field and just convert with ToNumber([Age Formula Text])
------------------------------
David Semitekol
------------------------------
Related Content
- 10 days agoShawnSchrotber1
- 17 days agoKathyBenjamin