If you are doing this for every row in your database, you might create a view rather than calculate row by row. You could add the Y & M as part of your report fields.
You could limit your view to "WHERE DeathDateTime IS NOT NULL" , or "WHERE DeathDateTime EXISTS." Might something like this work? CREATE VIEW LifeYrMo (YrsLife, MosLife) AS SELECT ( (DeathDateTime-BirthDateTime)/365.25), ( ( (MOD(YrsLife))*365.25)/30.44) FROM ... Randy ________________________________ From: rbase-l@googlegroups.com <rbase-l@googlegroups.com> on behalf of Bruce Chitiea <rby...@safesectors.com> Sent: Saturday, November 11, 2023 9:43 AM To: rbase-l@googlegroups.com <rbase-l@googlegroups.com> Subject: Re[2]: [RBASE-L] - Calculating Age in Years, Months | PRIVATE I apologize for using the word "ugly" <insert excuse here>. Rather, your code is elegant in that it really could not be reduced further without one helluva lot of work, as the 2016 approach suggests. I should have remembered my 9th grade geometry final, where, confronted with a jungular tangle of lines, I brute-forced my way to QED through thisHere angle equals thatThere angle in 23 steps. Thought I was all that. The girl next to me reached QED in three. As to being more versed ... doubtful. Best, Bruce ------ Original Message ------ >From "Charles Stevens" <stevens...@gmail.com<mailto:stevens...@gmail.com>> To rbase-l@googlegroups.com<mailto:rbase-l@googlegroups.com> Date 11/11/2023 7:29:29 AM Subject Re: [RBASE-L] - Calculating Age in Years, Months Hi, Bruce - Thanks for your time and response. I spent an inordinate amount of time and effort to create a working formula, and thought there must be an easier way. I had in mind a function similar to DATEDIF in Excel. Glad to have the opinion of someone more versed in R:Base than I am. I will use it - as is - in all its ugliness, since it works. Cheers, [http://img194.imagevenue.com/loc254/th_139623767_chuckstevens_122_254lo.jpg] On Fri, Nov 10, 2023 at 10:24 PM Bruce Chitiea <rby...@safesectors.com<mailto:rby...@safesectors.com>> wrote: Charles: Played with it a bit, searching for elegance. The only fully duplicated segment 'DOD - DOB' is wrapped on all sides by unique function strings, so atomization likely creates more work than it's worth. So, ugly it may be; but if it works ... Alternately, from the list in 2016: CLEAR VAR v% CLS SET VAR vBegDATE DATE = NULL SET VAR vEndDATE DATE = NULL SET VAR vBegTIME TIME = NULL SET VAR vEndTIME TIME = NULL SET VAR vBegDATE = (RDATE(4,21,2016)) SET VAR vEndDATE = (RDATE(4,27,2016)) SET VAR vBegTIME = (RTIME(10,20,0)) SET VAR vEndTIME = (RTIME(14,15,0)) SET VAR vBegDATETIME = (DATETIME(.vBegDATE, .vBegTIME )) SET VAR vEndDATETIME = (DATETIME(.vEndDATE, .vEndTIME )) SET VAR vElapsed_MIN = ((.vEndDATETIME - .vBegDATETIME)/60) SET VAR vElapsed_HR = (ROUND((.vElapsed_MIN/60),3)) SET VAR vElapsed_DAY = (ROUND((.vElapsed_HR/24),3)) SHOW VARIABLES V% RETURN Maybe there's some gold there. Best, Bruce Bruce A. Chitiea SafeSectors, Inc. 1142 S Diamond Bar Blvd # 442 Diamond Bar CA 91765-2203 rby...@safesectors.com<mailto:rby...@safesectors.com> (909) 238-9012 m ------ Original Message ------ >From "Charles Stevens" <stevens...@gmail.com<mailto:stevens...@gmail.com>> To rbase-l@googlegroups.com<mailto:rbase-l@googlegroups.com> Date 11/10/2023 1:36:33 PM Subject [RBASE-L] - Calculating Age in Years, Months Hello All - I am wondering if there is a more elegant way to find the difference between two days expressed as Years, Months, than what I have been using, below, which produces the results nny nnM, but seems clumsy: (CTXT(INT((DOD - DOB)/365.25))+'Y')&(CTXT(INT(MOD(DOD - DOB,365.25)/30.44))+'M') Where 'DOD'=Date of Death, 'DOB'=Date of Birth, 365.25=number of days in a year, and 30.44=number of days in a month. Seems to me this should be a commonly needed calculation. [http://img194.imagevenue.com/loc254/th_139623767_chuckstevens_122_254lo.jpg] -- For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php --- You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to rbase-l+unsubscr...@googlegroups.com<mailto:rbase-l+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/CADAyCN_2mA%3DZmh3jgYnEaRDZ3JWgudXfBNTdP_Km704YLuKGEA%40mail.gmail.com<https://groups.google.com/d/msgid/rbase-l/CADAyCN_2mA%3DZmh3jgYnEaRDZ3JWgudXfBNTdP_Km704YLuKGEA%40mail.gmail.com?utm_medium=email&utm_source=footer>. -- For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php --- You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to rbase-l+unsubscr...@googlegroups.com<mailto:rbase-l+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/emb1486432-408d-4603-94dc-fdd6aa373662%40ffc94789.com<https://groups.google.com/d/msgid/rbase-l/emb1486432-408d-4603-94dc-fdd6aa373662%40ffc94789.com?utm_medium=email&utm_source=footer>. -- For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php --- You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to rbase-l+unsubscr...@googlegroups.com<mailto:rbase-l+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/CADAyCN-eDQc%2B20aCaacxJth%3D3B-7aajOAO4kt9qy-3MfTqO9tA%40mail.gmail.com<https://groups.google.com/d/msgid/rbase-l/CADAyCN-eDQc%2B20aCaacxJth%3D3B-7aajOAO4kt9qy-3MfTqO9tA%40mail.gmail.com?utm_medium=email&utm_source=footer>. -- For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php --- You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to rbase-l+unsubscr...@googlegroups.com<mailto:rbase-l+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/em5c0c0571-c57b-4b66-b148-a7199a992f97%40ffc94789.com<https://groups.google.com/d/msgid/rbase-l/em5c0c0571-c57b-4b66-b148-a7199a992f97%40ffc94789.com?utm_medium=email&utm_source=footer>. -- For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php --- You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to rbase-l+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/PH0PR11MB5112E3FD8C4C35483AEF63B2C7ACA%40PH0PR11MB5112.namprd11.prod.outlook.com.