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

IF else function and DATE format

Started by learnflower, 16 Dec 2011 01:52:57 AM

Previous topic - Next topic

learnflower

HI ,

I am using this 
cast(cast((extract(month,current_date)), varchar(2)), integer)-1||'/'||cast(substring((cast((extract(year,current_date)), varchar(4)) ),3), integer)-1
in a if and else i am getting the 'sqlPrepareWithOptions' status='-126'
but without having it in the if condition if i=run the tabular data i am getting required output .

But within the below if condition i am getting the below mentioned error

IF (cast((extract(month,current_date)), varchar(2))>'01')
THEN
  (cast((extract(month,current_date)), varchar(2))||'/'||substring((cast((extract(year,current_date)), varchar(4)) ),3))
ELSE
   (cast(cast((extract(month,current_date)), varchar(2)), integer)-1||'/'||cast(substring((cast((extract(year,current_date)), varchar(4)) ),3), integer)-1)

Please guide on this

blom0344

Looks to me you are trying to concatenate (   ||  )  strings and numerical values

Also why define:

(cast((extract(month,current_date)), varchar(2))>'01')

instead of:

extract(month,current_date) > 1

You need to clean your code..

learnflower


blom0344

You're welcome! Now if you could just write my name properly   ;)

learnflower

Sorry  :) for not writing ur name properly blom0344

MFGF

Quote from: blom0344 on 19 Dec 2011 01:44:35 AM
You're welcome! Now if you could just write my name properly   ;)

Hee hee. Makes me smile every time! :)

Thanks Blom - you are a star!
Meep!

blom0344

I fear this is becoming a running gag   :-\