Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

why doesn't this work?

if(Created_On=>'01.04.2010' or Created_On<='31.03.2011','10/11',

if(Created_On=>'01.04.2011' or Created_On<='31.03.2012','11/12')) as COD

7 Replies
Anonymous
Not applicable
Author

Hi

     May be the date  format is mismatched.

     You will try using the num() function before your operands.

i.e

example

     num(created_On) => num(01.04.2010)  ....

Regards

Ashok

jagan
Luminary Alumni
Luminary Alumni

Hi,

You have to use '>=' instead of '=>', and one more thing both the date formats should be same.

if(Created_On >= '01.04.2010' or Created_On <= '31.03.2011','10/11',

if(Created_On >= '01.04.2011' or Created_On <= '31.03.2012','11/12')) as COD

Hope this helps you.

Regards,

Jagan.

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

Try with this

    

if(Created_On>= Date(Date#('01.04.2010')) and Created_On<=Date(Date#('31.03.2011')),'10/11',

if(Created_On>=Date(Date#('01.04.2011')) and Created_On<=Date(Date#('31.03.2012')),'11/12')) as COD

Hope it helps

Celambarasan

rahulgupta
Partner - Creator III
Partner - Creator III

Hey Hi,

Use this

if(Date(Created_On,'DD.MM.YYYY') =>'01.04.2010' or  Date(Created_On,'DD.MM.YYYY') <='31.03.2011','10/11',

if(Date(Created_On,'DD.MM.YYYY')=>'01.04.2011' or  Date(Created_On,'DD.MM.YYYY')<='31.03.2012','11/12')) as COD

Regards

Rahul Gupta

flipside
Partner - Specialist II
Partner - Specialist II

If you want a more dynamic option, I use something like this which means you don't have to keep going back to add/change the date test values, it just uses the actual year in the date ...

YrMap:
MAPPING LOAD * INLINE [
    Month, Adjust
    1,-1
    2,-1
    3,-1];

Data:
LOAD * INLINE [
    Date
    01/01/2010
    23/02/2011
    03/06/2010
    01/04/2011
    31/03/2011
];

FiscalData:
LOAD
Date as FiscalDate,
Right(Year(Date) + ApplyMap('YrMap',Month(Date),0),2)
  & '/' & Right(Year(Date) + ApplyMap('YrMap',Month(Date),0)+1,2) as FiscalYr
RESIDENT Data;

flipside

Not applicable
Author

get

Error in expression:
')' expected
IFLOT:
LOAD Functional_Location,
     Waste_Water_Receiver,

if(Date(Created_On,'YYYY-MM-DD') =>'2010-04-01' or  Date(Created_On,'YYYY-MM-DD') <='2011-03-31','10/11',
if(Date(Created_On,'YYYY-MM-DD')=>'2011-04-01' or  Date(Created_On,'YYYY-MM-DD')<='2012-03-31','11/12')) as COD


so no good

Not applicable
Author

you need to use >= and not =>