Print Page | Close Window

How to Show Time Range in crystal report

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=741
Printed Date: 02 May 2025 at 12:35am


Topic: How to Show Time Range in crystal report
Posted By: kisetsu
Subject: How to Show Time Range in crystal report
Date Posted: 24 May 2007 at 12:05am
Hi All, I am using crystal report for Visual Studio 2003.
My report is on daily basis. Data is taken from MS SQL DB 2K.
If data is not present for one specific then I need to just let it be empty.
e.g. of the time range :
Time | 8:00|8:10| 8:20|8:30 |8:40 |8:50|9:00|...

I wanna generate time start from 8 am to 8 pm , interval : 10min.
I tried to generate time by sql query. But when i show in report(put the field in details section), it will show as vertical. Got other where to generate the times and show in report?

Plus each time interval may be will have more than one record. Example :
at 8 am, production cut 3 size. each size is different qty.
HOw to put 3 records into same time interval?

Anyone got any idea for my problems?

Really appreaciate your help

Thanks in Advance.

Best Regards,
Kisetsu



Replies:
Posted By: hilfy
Date Posted: 28 May 2007 at 1:16pm

In order to show ALL times, even those without data, your times would have to be in your data - usually in a data table.

I would see about creating a table with something like the following structure:

TIME_GROUPS

START_HOUR             Number(2)
START_MINUTE          Number(2)
END_MINUTE             Number(2)
GROUP_NAME  Varchar(15)
 
Your data in this table would look something like this:
 
Start Hour   Start_Minute    End_Minute    Group_Name
8                 0                       10                   8:00
8                 10                     20                   8:10
...
8                 50                     60                   8:50
...
13               0                       10                   1:00
 
You'll notice how I set up the "end minute" for the last block of the hour as 60 - this will help you do the comparison in your SQL.  I also set this up to work on a 24-hour clock - also to make it easier to do the comparisons in SQL.
 
I work in Oracle and I'm not familiar with which commands are the same between Oracle and MS SQL and which are not, so you may need to translate some of this into something MS SQL would understand.  But, I would do something like this in my SQL:
Select tg.GROUP_NAME,
          t.LAST_CHANGE_DATE,
          t.FIELD1,
          t.FIELD2
from Table1 as t
left join Time_Groups as tg 
  on tg.START_HOUR = To_Number(To_Char(t.LAST_CHANGE_DATE, 'HH24'))
where To_Number(To_Char(t.LAST_CHANGE_DATE, 'MI'))
    between tg.START_MINUTE and tg.END_MINUTE
In the report, I would then set up a group on the GROUP_NAME field, a Sort on the LAST_CHANGE_DATE field, and put my data in the details.  This way your data will be grouped together in your 10-minute time-slots and then in time-order within those time slots.
 
-Dell 


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window