简体   繁体   English

当日期为 YYYY-MM-DD 格式时,如何使用 SSRS 仅在月份进行过滤?

[英]How can I use SSRS to filter just on month when the date is in YYYY-MM-DD format?

我想忽略年份和日期......例如,如果 2018-09-08 和 2016-09-04 存在两个不同的 personID,如果我将月份过滤为“九月”,我希望两行日期都出现

Assuming you want to do this in the dataset filter properties rather than in your dataset query and also assuming you have a report parameter called @pMonth then you can add a filter to the dataset.假设您想在数据集过滤器属性中而不是在数据集查询中执行此操作,并且还假设您有一个名为@pMonth的报告参数,那么您可以向数据集添加过滤器。

Set the filter expression to =Month(Fields!myDateColumn.Value) and the value expression to =Parameters!pMonth.Value将过滤器表达式设置为=Month(Fields!myDateColumn.Value)并将值表达式设置为=Parameters!pMonth.Value

If you wanted to only ever show the records that match the parameter then it's best to do this in the dataset query, that way you only return what you need rather than return lots of data that never gets used.如果您只想显示与参数匹配的记录,那么最好在数据集查询中执行此操作,这样您只会返回您需要的内容,而不是返回大量从未使用过的数据。

To do this in SQL Server you would do something similar...要在 SQL Server 中执行此操作,您将执行类似的操作...

SELECT * 
    FROM myTable t 
    WHERE MONTH(t.myDateColumn) = @pMonth

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

相关问题 如何在 sql 中将日期格式从 YYYY-MM-DD 转换为 YYYY-MM - How can I convert date format from YYYY-MM-DD to YYYY-MM in sql 如何将“yyyy-mm/dd”中的日期转换为“yyyy-mm-dd” - How can I convert a date that's in "yyyy-mm/dd" to "yyyy-mm-dd" 如何格式化sql日期(yyyy-mm-dd)以在jsp中显示为(yyyy)? - How to format sql date (yyyy-mm-dd) to display as just (yyyy) in jsp? 将 mm/dd/yyyy 传递给 yyyy-mm-dd 日期格式 - Pass mm/dd/yyyy to yyyy-mm-dd date format Teradata:如何将varchar值(格式'dd.mm.yyyy')转换为日期(格式'yyyy-mm-dd')? - Teradata: how to convert varchar value (format 'dd.mm.yyyy') to date (format 'yyyy-mm-dd' )? 如何在 SQLite 中将文本转换为日期(YYYY-MM-DD 格式) - How to convert text to date (YYYY-MM-DD format) in SQLite 如何将mm / dd / yyyy格式的日期转换为yyyy-mm-dd hh:mi:ss.mmm - How to convert date in mm/dd/yyyy format to yyyy-mm-dd hh:mi:ss.mmm 如何在 PL/SQL 中将日期格式从 MM/DD/YYYY 更改为 YYYY-MM-DD? - How to change the date format from MM/DD/YYYY to YYYY-MM-DD in PL/SQL? netezza 将 YYYY-MM-DD 格式的字符日期与 yyyy-mm-dd 格式的参数日期进行比较 - netezza compare char date in YYYY-MM-DD format to parameter date in yyyy-mm-dd format 如何使用SQL将日期格式转换为YYYY-MM-DD - How do I convert date format to YYYY-MM-DD with SQL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM