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.
Calculate Months Since from Date
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 142
- Joined: Mon Jun 27, 2005 5:31 pm
- Location: Atlanta GA
Calculate Months Since from Date
Venkat Velagapudi
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.