Sql 根据用户提供的日期筛选数据
我有一个SQL查询,如下所示:-Sql 根据用户提供的日期筛选数据,sql,sql-server,tsql,reporting-services,Sql,Sql Server,Tsql,Reporting Services,我有一个SQL查询,如下所示:- select * from dbo.NGPTimesheetsPosition where ProjectNO = '12169-01-c' AND CreditorEmployeeID <> 'E0000' AND DocType = 'Time Sheet' 选择* 从dbo.NGPTimesheetsPosition开始 其中ProjectNO='12169-01-c',creditoreemployeeid'E0000',DocType=
select *
from dbo.NGPTimesheetsPosition
where ProjectNO = '12169-01-c' AND CreditorEmployeeID <> 'E0000' AND DocType = 'Time Sheet'
选择*
从dbo.NGPTimesheetsPosition开始
其中ProjectNO='12169-01-c',creditoreemployeeid'E0000',DocType='timesheet'
这将返回以下数据:
我想做的是能够仅显示用户定义日期之前(包括该日期)的数据,例如2013年2月1日
用户定义的日期可以是当前月份之前的任何日期
非常感谢所有帮助或建议。选择*
select *
from dbo.NGPTimesheetsPosition
where ProjectNO = '12169-01-c' AND CreditorEmployeeID <> 'E0000' AND DocType = 'Time Sheet'
and TransactionDate <= '2013-02-01'
从dbo.NGPTimesheetsPosition开始
其中ProjectNO='12169-01-c',creditoreemployeeid'E0000',DocType='timesheet'
和TransactionDate在where子句中进行如下日期比较
Convert(varchar(11),transactiondate,101)您需要在数据集查询中使用以下参数:
SELECT *
FROM dbo.NGPTimesheetsPosition
WHERE ProjectNO = '12169-01-c'
AND CreditorEmployeeID <> 'E0000'
AND DocType = 'Time Sheet'
AND TransactionDate <= @MyDateParameter -- ADDED!
选择*
从dbo.NGPTimesheetsPosition开始
其中ProjectNO='12169-01-c'
和贷记员工ID“E0000”
和DocType='时间表'
及交易日期