If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Date differences by year and month

Started by ynlye, 15 Mar 2021 05:00:57 AM

Previous topic - Next topic

ynlye

Hi guys,


So far i only know how to use this _months_between to get the months differences.
My question is if i get 125months from the code shown in below, how am i going to get something like 10 years 5 months from 125months?

_months_between ([SQL3].[orig],[SQL3].[cdd3])

MFGF

Quote from: ynlye on 15 Mar 2021 05:00:57 AM
Hi guys,


So far i only know how to use this _months_between to get the months differences.
My question is if i get 125months from the code shown in below, how am i going to get something like 10 years 5 months from 125months?

_months_between ([SQL3].[orig],[SQL3].[cdd3])

Hi,

There are a couple of approaches you could take for this:

1. Stick with the number of months returned from the _months_between calculation, and add calculations to work out the years and months
    - Years would be floor([your number of months] / 12)
    - Months would be mod([your number of months], 12)

2. Instead of _months_between use _ymdint_between. This returns a result in the form YYYYMMDD. Obviously you don't need the days in this case, but you could then add calculations to take out the years and months from this
    - Years would be floor([your YYYYMMDD value] / 10000)
    - Months would be mod(floor([your YYYYMMDD value] / 100), 100)

Cheers!

MF.
Meep!