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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping by Time 1

Status
Not open for further replies.

mwake

Programmer
Feb 12, 2004
151
US
I am creating a report of downloads per week and would like to group them by time (ex. Midnight-6:00AM, 6:00AM-Noon, Noon-6:00PM, 6:00PM-Midnight). I can do this with a long if/then statement, but I was wondering if there was a more efficient way. Any ideas??
 
Depends on what is meant by a loooong if/then.

Also the version of Crystal matters, as with most software solutions.

A standard might be to use something like:

if hour({table.datetime}) <= 6 then
1
else
if hour({table.datetime}) <= 12 then
2
else
if hour({table.datetime}) <= 18 then
3
else
4

You might also use a Case or an IIF.

-k

-k
 
Or you can do it this way

Code:
Select hour({table.datetime})
Case 0 to_ 6:
  1
Case 6 to_ 12:
  2
Case 12 to_ 18:
  3
default:
  4

-LW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top