Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formulas to groupe on.

Status
Not open for further replies.

gazol

Technical User
Jan 29, 2004
31
SE
Using: Crystal reports 8.5, ODBC, ORACLE.

I have 2 formulas that i select between with a parameter and it works fine.

I want to be able to create another parameter called "Week" and when i choose "Week" i want the grouping to be done for each week. (Formula 2 is not the problem to do it on, i guess (week({TABLE.TIME}) will work.

I want the week to start on mondag (day2 in crystal) not on sunday. (I´m from europe)

Can anyone help me to modify this formulas to be able to groupe on week as well ?


Formula 1 ----

if {?time_group_parameter} = "Hour" Then
cstr({TABLE.TIME},"yyyy-MM-dd HH:00")
else if {?time_group_parameter} = "Day" then
cstr({TABLE.TIME},"yyyy-MM-dd")
else
cstr({TABLE.TIME},"yyyy-MM")
------------------------------------------

Formula 2 ----

if ucase({?time_group_parameter}) = 'Day' then
totext(day({TABLE.TIME}))
else if ucase({?time_group_parameter}) = 'Month' then
totext(month({TABLE.TIME}))
else if ucase({?time_group_parameter}) = 'Hour' then
totext(Hour({TABLE.TIME}),0)&":00"
-----------------------------------------------


Regards / GaZoL


 
For the week group, use:

totext(datepart("ww",{table.time},crMonday),"00")

By using the "00", the numberic string should sort correctly.

-LB
 
Thanks lbass, seems to work perfekt :)

Anyone who has any ideas for this formula to be able to groupe on week ?
-------------------------------

if {?time_group_parameter} = "Hour" Then
cstr({TABLE.TIME},"yyyy-MM-dd HH:00")
else if {?time_group_parameter} = "Day" then
cstr({TABLE.TIME},"yyyy-MM-dd")
else
cstr({TABLE.TIME},"yyyy-MM")

-------------------------------
Regards / Gazol
 
Do you want the formula to display the first day of the week?

-LB
 
The week number is what i want displayed. Just like in the first formula :)

(and the groupe must contain the week starting from mondag to sunday)


/ Gazol
 
Same solution:
if {?time_group_parameter} = "Hour" Then
cstr({TABLE.TIME},"yyyy-MM-dd HH:00")
else if {?time_group_parameter} = "Day" then
cstr({TABLE.TIME},"yyyy-MM-dd")
else if {?time_group_parameter} = "Week" then
totext(datepart("ww",{TABLE.TIME},crMonday),"00")
else
cstr({TABLE.TIME},"yyyy-MM")

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top