3 Replies Latest reply: Feb 22, 2012 5:36 AM by mrpjspencer

# Sorting data by years

Good morning people! i'm having a problem with the following script,

its only giving me data from the 0-1 year line and is ignoring the rest.

if(today()-Due_Date>=0 or Today()-Due_Date<=365,'0-1 Years',

if(today()-Due_Date>=366 or Today()-Due_Date<=730,'1-2 Years',

if(today()-Due_Date>=731 or Today()-Due_Date<=1096,'2-3 Years',

if(today()-Due_Date>=1097 or Today()-Due_Date<=1461,'3-4 Years',

if(today()-Due_Date>=1462,'4+ Years'))))) as Years

Any ideas why this is doing this?

Kind Regards.

Paul.

• ###### Sorting data by years

Hi,

You should use and condition instead of or condition here both to be satisfied.

if(today()-Due_Date>=0 and Today()-Due_Date<=365,'0-1 Years',

if(today()-Due_Date>=366 and Today()-Due_Date<=730,'1-2 Years',

if(today()-Due_Date>=731 and Today()-Due_Date<=1096,'2-3 Years',

if(today()-Due_Date>=1097 and Today()-Due_Date<=1461,'3-4 Years',

if(today()-Due_Date>=1462,'4+ Years'))))) as Years

Hope it helps

Celambarasan

• ###### Sorting data by years

Thankyou! Much appreciated!

• ###### Sorting data by years

Hi,

Use AND instead of OR in the If statement.

Regards,

Jagan.