PDA

Click to See Complete Forum and Search --> : [CR 8.5]How convert data format to YYYY only


nUflAvOrS
Aug 29th, 2007, 01:22 AM
Hi all,

I have a report contains a field in date format

Example : 21 / 08 / 2007

I would like convert it to "mmm/yyyy"

I use the code in edit formula like this


MonthName(Month({Table.Date1}),True) & " / " & year({Table.Date1})



However, my return format is : Aug / 2007.00
How can i make it return format = Aug / 2007


Your help is much appreciated. Thanks you;)

nUflAvOrS
Aug 29th, 2007, 03:03 AM
i had solved the problem by using mid

But i wondered is it the best solution.


MonthName(Month({Table.Date1}),True)& " / " & replace(mid(cstr(year({Table.Date1})),1,5),","," ")

brucevde
Aug 29th, 2007, 09:41 AM
Crystal has a ToText function. The second argument of the function indicates how many decimal places to include.

ToText(Year({Table1.Date}), 0)

svobill
Aug 29th, 2007, 10:37 AM
The solution that brucevde propsed also works with the Crystal Basic CStr function:

CStr(Year({Table1.Date}), 0)

techgnome
Aug 29th, 2007, 11:49 AM
can't you just drop the date field onto the report and change it's format to display MM/YYYY? We do that a lot... esp in our report headers. We'll pass in a date as a parameter, like "8/1/2007", then in the report, drop the parameter onto the report, right-click, format (or it maybe properties), and set the format so that it gives "Aug 2007".

-tg

nUflAvOrS
Aug 29th, 2007, 08:37 PM
Thanks svobill and brucedve, u shorted my coding

techgnome u might misunderstood my problem or i didnt make it clearly i need to group it afterward, thanks you a lot....