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 format issue

Started by Raghuvir, 10 Dec 2014 03:15:53 AM

Previous topic - Next topic

Raghuvir

Hi all,

i have a data item with the following condition written in it.

cast(Day([Empl_Payroll].[VALUE_DATE]),varchar(2))||'-'||
CASE
WHEN  Month([Empl_Payroll].[VALUE_DATE])=1  THEN ('Jan')
WHEN  Month([Empl_Payroll].[VALUE_DATE])=2  THEN ('Feb')
WHEN  Month([Empl_Payroll].[VALUE_DATE])=3  THEN ('Mar')
WHEN  Month([Empl_Payroll].[VALUE_DATE])=4  THEN ('Apr')
WHEN  Month([Empl_Payroll].[VALUE_DATE])=5  THEN ('May')
WHEN  Month([Empl_Payroll].[VALUE_DATE])=6  THEN ('Jun')
WHEN  Month([Empl_Payroll].[VALUE_DATE])=7  THEN ('Jul')
WHEN  Month([Empl_Payroll].[VALUE_DATE])=8  THEN ('Aug')
WHEN  Month([Empl_Payroll].[VALUE_DATE])=9  THEN ('Sep')
WHEN  Month([Empl_Payroll].[VALUE_DATE])=10  THEN ('Oct')
WHEN  Month([Empl_Payroll].[VALUE_DATE])=11  THEN ('Nov')
WHEN  Month([Empl_Payroll].[VALUE_DATE])=12 THEN ('Dec')
ELSE  ('None')
END
||'-'||
substring(cast(year([Empl_Payroll].[VALUE_DATE]),varchar(4)),3,2)

when place the data item on the layout and run the report the date what i get is "4-Dec-14" whereas i want it to be "04-Dec-14"

Request you to guide me to achieve this.

Regards

RandomHunter

Hi,

try replacing the first part by this:

if ( Day([Empl_Payroll].[VALUE_DATE])  < 10 )
then ('0')
else ('') || '-' || cast(Day([Empl_Payroll].[VALUE_DATE]),varchar(2))

Regards,
Hunter


bdbits

If VALUE_DATE is a real date datatype, as it appears to be in your expression, you are working way too hard. Just drop the column on your report, right-click and choose Style > Data format, pick Date from the Format type dropdown. Scroll down the options on the right and enter dd-MMM-yy in Pattern.