Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Can someone assist with the attached QV application. I am calculating product portfolio age based on an "Action Date" and today' s date. I have two ages, one is the PortfolioAge and the other PortfolioAgeLong. The PortfolioAge is in numeric form so that i can be able to use the class function to build charts with product age class intervals. The PortfolioAgeLong should give the true product age from the "ActionDate" in years, months and days.
The application seems not to be calculating the right ages as can be seen from the example below when reference is made to the ActionDate and today's date which means there is something wrong with the script:
Please assist
Regards.
Chris
Message was edited by: Christopher Chitemerere Removed the calculation of fractional ages as this has been answered by Gysbert
See here:Re: Age in Year Month Day Format
age(Today(),MCAZActionDate) & ' Years and ' &(if(day(Today()) >= day(MCAZActionDate),
mod((Year(Today())*12+Month(Today()))-(Year(MCAZActionDate)*12+Month(MCAZActionDate)),12),
if(mod((Year(Today())*12+Month(Today()))-(Year(MCAZActionDate)*12+Month(MCAZActionDate)),12)=0,11,mod((Year(Today())*12+Month(Today()))-(Year(MCAZActionDate)*12+Month(MCAZActionDate)),12)-1))) &' Months and ' &
(if(day(Today()) >= day(MCAZActionDate), day(Today()) - day(MCAZActionDate), Today()-AddMonths(MCAZActionDate,12*age(Today(),MCAZActionDate)+mod(Year(Today())*12+Month(Today())-Year(MCAZActionDate)*12+Month(MCAZActionDate),12)-1))+1) & ' days'
The Age function returns an integer value. If you want fractions the you'll have to use something like (Today()-MCAZActionDate)/365
Many thanks Gysbert for an answer to the last part of my question. The ages calculated in the application are wrong, can you assist on this through the attached application?
See here:Re: Age in Year Month Day Format
age(Today(),MCAZActionDate) & ' Years and ' &(if(day(Today()) >= day(MCAZActionDate),
mod((Year(Today())*12+Month(Today()))-(Year(MCAZActionDate)*12+Month(MCAZActionDate)),12),
if(mod((Year(Today())*12+Month(Today()))-(Year(MCAZActionDate)*12+Month(MCAZActionDate)),12)=0,11,mod((Year(Today())*12+Month(Today()))-(Year(MCAZActionDate)*12+Month(MCAZActionDate)),12)-1))) &' Months and ' &
(if(day(Today()) >= day(MCAZActionDate), day(Today()) - day(MCAZActionDate), Today()-AddMonths(MCAZActionDate,12*age(Today(),MCAZActionDate)+mod(Year(Today())*12+Month(Today())-Year(MCAZActionDate)*12+Month(MCAZActionDate),12)-1))+1) & ' days'
Thank you very much
Regards.