fuzzyocelot
Programmer
Hi, everyone!
We’re using SQL Server 2000 and Crystal Reports 9.
‘Faxes’ Table:
Handle DateTime Initiated DateTime Sent Difference (in seconds)*
1 2003-09-03 8:02:39 2003-09-03 8:02:50 11
2 2003-09-03 8:47:44 2003-09-03 8:47:45 1
3 2003-09-03 9:05:14 2003-09-03 9:05:29 15
4 2003-09-03 9:31:07 2003-09-03 9:31:11 4
* Note: in the table above, the "difference" field is actually calculated by a SQL expression (%chkDateDiff)within Crystal (see below). It's not in the physical table. I put it in the table above to try and simplify this post.
The data is displayed in a line chart, which is in the Report Header b section. The Report Title is in Report Header a. The chart’s y-axis shows the seconds and the x-axis shows the groupings, such as “09/03/2003 8:00 am”.
Group Header (which is suppressed):
09/03/2003 8:00 am
09/03/2003 9:00 am
The field in the group footer below is a formula which is listed further down the page (@avgDelay).
Group Footer (average seconds at 8:00 am and 9:00 am, respectively; this section is also suppressed):
6.00
9.50
SQL Expression used:
[tt]%chkDateDiff:
{fn IFNULL(DATEDIFF(Second, "Faxes"."DateTimeInitiated", "Faxes"."DateTimeSent", 0)}[/tt]
The expression above should determine the difference (in seconds) between the two date time fields. Also if the result is null, change it to zero.
Formulas used:
[tt]@DTCon:
dateVar conDate := CDate ({Faxes.DateTimeSent});
timeVar ConTime := CTime ({Faxes.DateTimeSent});
CDateTime (conDate,conTime)
@avgDelay:
Average ({%chkDateDiff},{@DTCon},"By Hour"
Record Selection formula:
{%chkDateDiff} >= 0 [/tt]
The database returns over 25,000 records, which is correct. The report looks great. How can I have the database return fewer records? I'd like to use the SQL expressions more, but I can't seem to figure out how to code the right expressions. We’ve decided to not use a SQL command because it hard codes the data source in it. So if the dsn changes (which happens too often for my taste), we’d have to rewrite the command. Feel free to tell me if I'm wrong.
Any ideas would be much appreciated.
Thanks!
We’re using SQL Server 2000 and Crystal Reports 9.
‘Faxes’ Table:
Handle DateTime Initiated DateTime Sent Difference (in seconds)*
1 2003-09-03 8:02:39 2003-09-03 8:02:50 11
2 2003-09-03 8:47:44 2003-09-03 8:47:45 1
3 2003-09-03 9:05:14 2003-09-03 9:05:29 15
4 2003-09-03 9:31:07 2003-09-03 9:31:11 4
* Note: in the table above, the "difference" field is actually calculated by a SQL expression (%chkDateDiff)within Crystal (see below). It's not in the physical table. I put it in the table above to try and simplify this post.
The data is displayed in a line chart, which is in the Report Header b section. The Report Title is in Report Header a. The chart’s y-axis shows the seconds and the x-axis shows the groupings, such as “09/03/2003 8:00 am”.
Group Header (which is suppressed):
09/03/2003 8:00 am
09/03/2003 9:00 am
The field in the group footer below is a formula which is listed further down the page (@avgDelay).
Group Footer (average seconds at 8:00 am and 9:00 am, respectively; this section is also suppressed):
6.00
9.50
SQL Expression used:
[tt]%chkDateDiff:
{fn IFNULL(DATEDIFF(Second, "Faxes"."DateTimeInitiated", "Faxes"."DateTimeSent", 0)}[/tt]
The expression above should determine the difference (in seconds) between the two date time fields. Also if the result is null, change it to zero.
Formulas used:
[tt]@DTCon:
dateVar conDate := CDate ({Faxes.DateTimeSent});
timeVar ConTime := CTime ({Faxes.DateTimeSent});
CDateTime (conDate,conTime)
@avgDelay:
Average ({%chkDateDiff},{@DTCon},"By Hour"
Record Selection formula:
{%chkDateDiff} >= 0 [/tt]
The database returns over 25,000 records, which is correct. The report looks great. How can I have the database return fewer records? I'd like to use the SQL expressions more, but I can't seem to figure out how to code the right expressions. We’ve decided to not use a SQL command because it hard codes the data source in it. So if the dsn changes (which happens too often for my taste), we’d have to rewrite the command. Feel free to tell me if I'm wrong.
Any ideas would be much appreciated.
Thanks!