如何在Crystal报表中显示日期范围 [英] How to display a date range in crystal report

查看:215
本文介绍了如何在Crystal报表中显示日期范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个应用程序,当我想运行报表以在Crystal报表上打印时,我有两个DayTimePicker从一个日期到另一个日期进行选择,以过滤数据库中的数据,但我的数据库中只有一个日期列.

如何在生成的水晶报表上同时显示从DayTimePicker中选择的日期范围.

例如.

从:DateTimePicker1到:DateTimePicker2

我尝试过的事情:

我所做的只是选择日期列并将其放置在报告模板的第1部分标题中,但它仅在模板上显示DayTimePicker1选定的日期,而在第3部分(水晶报表中的详细信息)中,它按查询过滤了选定的日期. div class ="h2_lin">解决方案

我不知道如何从数据库中检索数据以及正在使用哪个数据库,但是如果您对数据库使用SQL,则使用存储过程,其中参数包括从日期到日期,您可以通过在数据库中的日期列之间使用之间进行过滤.

例如.

创建过程spWhatever
@startDate日期,
@endDate日期

开始
-在这里做您的选择语句
从tlbName中选择*,其中@startDate和@endDate之间的date_column
结束


在报告上,将您的datetimepickers设置为将值传递给@startDate和@endDate参数,在报告模板上,将参数传递给

从:[@startDate]到:[@endDate]


Hello Everyone,

I Have an application that when i want to run a report to print on crystal report, i have two DayTimePicker to choose from one date to another to filter the data from the database but i only have a one single colunm for date in my database.

How can i display the selected date range from both the DayTimePicker on my crystal report generated.

eg.

From: DateTimePicker1 To: DateTimePicker2

What I have tried:

all i did is to pick the date column and place on my report template Section 1 header but it shows only the DayTimePicker1 selected date on the template but in my Section 3 which is the details in crystal report it filtered the selected dates as queried.

解决方案

I don''t know how you retrieve your data from the database and which database are you using, but if you using SQL for your database use a stored procedure where the parameters include from date and to date, you can filter this by using between on the date column in the db.

eg.

create procedure spWhatever
@startDate date,
@endDate date
as
begin
--do your select statement here
select * from tlbName where date_column between @startDate and @endDate
end


on the report set your datetimepickers to pass the values to the @startDate and @endDate parameters and on the report template pass the parameters

From: [@startDate] To: [@endDate]


这篇关于如何在Crystal报表中显示日期范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆