Page 1 of 1

Calculate Months Since from Date

Posted: Mon Oct 01, 2012 12:26 pm
by velagapudi_k
Folks, I am trying to calculate number of months since from a given date.
I know Datastage has DaysSinceFromDate and I can do either
days/30 or (days/365)*12. The second one is much accurate. Please let me know if there is a better way. Appreciate your help.

Posted: Tue Oct 02, 2012 8:10 am
by ArndW
Compute the YYYY and the MM from a date and compute X as ((YYYY*12)+MM). Do the same for the other date and subtract the larger from the smaller. This returns 0 for (2012-08-31::2012-08-31) and 1 for (2012-08-31::2012-09-01) and would be the number of calendar months between the two dates and might be a better value than rouding the number of days to months -- but it depends upon what the end-user/customer really wants.