PawelBor
PawelBor

Reputation: 5

Crystal Reports - Combine Rows

I'm very new to Crystal Reports and I've one little problem. I'll be quick and on point.

The columns are as follow: 2016-01-05, 2016-01-06, 2016-01-07, 2016-01-08, 2016-01-09 (list goes on till end of year) These dates come from Database field called NextDueDate and it populates the report with all the dates.

My question, is it possible to combine these rows or group them by weeks or perhaps by month?

Result I'm looking for is: 2016-01 (All january days combined here) or something like maybe even just January etc.

NextDueDate field is type string by the way. Also, I'd like to do this without getting involved in the actual database itself due to specific reasons.

Upvotes: 0

Views: 121

Answers (1)

Ankur Alankar Biswal
Ankur Alankar Biswal

Reputation: 1182

you can use this simple formula as

@year_month = left ({NextDueDate},7);

enter image description here

create formula as year_month

and put left ({NextDueDate},7); in formula editor click on save.

enter image description here

now you can see this formula under formula field in field explorer.

Drag this one to your detailed section.
You can group the result based on this formula.

                    OR

user these formula

@year_month = left ({NextDueDate},7);
@monthOnly = right( @year_month , 2);
@FullMonthName = if @monthOnly = '01' then 'January'
                 else if {@month} = '02' then 'February'
                 ........................................
                 else 'December';

Upvotes: 1

Related Questions