我有以下查询,我正在尝试选择日期范围之间的所有记录,但我想排除周末...有人知道是否可以这样做吗?
SQL不是我的强项!
以下是查询;
SELECT
tblTime.*,
tblProjects.fldProjectDesc,
tblProducts.fldProductID,
tblProducts.fldProductDesc
FROM (tblTime
INNER JOIN tblProjects
ON tblTime.fldProjectID = tblProjects.fldProjectID)
INNER JOIN tblProducts
ON tblProjects.fldProduct = tblProducts.fldProductID
WHERE fldUserCode = 'pac'
AND fldDate BETWEEN CONVERT(varchar, '13/11/2015', 103) AND CONVERT(varchar, '15/11/2015', 103)
ORDER BY fldDate
感谢您的帮助!
答案 0 :(得分:1)
使用Dataname
功能
SELECT tbltime.*,
tblprojects.fldprojectdesc,
tblproducts.fldproductid,
tblproducts.fldproductdesc
FROM (tbltime
INNER JOIN tblprojects
ON tbltime.fldprojectid = tblprojects.fldprojectid)
INNER JOIN tblproducts
ON tblprojects.fldproduct = tblproducts.fldproductid
WHERE fldusercode = 'pac'
AND flddate BETWEEN CONVERT(VARCHAR, '13/11/2015', 103) AND
CONVERT(VARCHAR, '15/11/2015', 103)
AND Datename(weekday, flddate) NOT IN ( 'Saturday', 'Sunday' )
ORDER BY flddate