简体   繁体   English

SSRS 2008中的日期过滤器

[英]Date Filter in SSRS 2008

I am working with SSRS 2008. I have a table in my report consisting a date/Time Column (DOB). 我正在使用SSRS 2008.我的报告中有一个包含日期/时间列(DOB)的表。 I have a date/time parameter (MyDate) as well. 我也有一个日期/时间参数(MyDate)。 I am trying to set a Filter on my data set like 我试图在我的数据集上设置一个过滤器

FormatDateTime(Fields!DOB.Value,2)<=FormatDateTime(Parameters!MyDate.Value,2)

It doesn't filter my table correctly. 它没有正确过滤我的表格。 But if I remove FormatDateTime function then it works fine. 但是,如果我删除FormatDateTime函数,那么它工作正常。 i want to understand whats the problem here. 我想了解这里的问题是什么。

FormatDateTime will return a string, so you're not comparing dates anymore but rather their string representations. FormatDateTime将返回一个字符串,因此您不再比较日期,而是比较它们的字符串表示形式。

Comparing the dates 02-Feb-2012 and 10-Oct-2012 will give different results than comparing the strings 2/2/2012 and 10/10/2012 . 比较02-Feb-2012 10-Oct-2012 02-Feb-2012的日期将比比较字符串2/2/201210/10/2012提供不同的结果。

As mentioned in the comment, it looks like you're just trying to remove the time portion from dates? 正如评论中所提到的,看起来你只是想从日期中删除时间部分?

Something like this should work, ie converting the strings back to dates. 像这样的东西应该工作,即将字符串转换回日期。

CDate(FormatDateTime(Fields!DOB.Value,2)) <= CDate(FormatDateTime(Parameters!MyDate.Value,2))

But this is just one suggestion, there are any number of ways of doing this. 但这只是一个建议,有很多方法可以做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM