将日期和/或时间从字符串转换为星期数时,转换失败

时间:2020-01-10 16:38:16

标签: sql date-conversion

我无法转换此脚本以在BIRT中使用。

这在我不使用DATEPART(Week,[week])时有效,但是我想用它来显示星期数。现在,最后3个AND命令正在引起错误,我不明白为什么。有人可以建议,因为我对SQL还是很陌生。

SELECT          stocktransactions.type, 
                stocktransactions.createddate, 
                stocktransactions.referencedate AS tradate, 
                Datepart(week,[week])           AS week, 
                stocktransactions.partid, 
                stocktransactions.partrevisionid, 
                stocktransactions.quantity, 
                stocktransactions.locationid, 
                stocktransactions.reference, 
                stocktransactions.source, 
                stocktransactions.stockvalue, 
                stocktransactions.batchnumber, 
                stocktransactions.warehouseid, 
                stocktransactions.stocktaketicket, 
                stocktransactions.worksorderid, 
                stocktransactions.createdby, 
                stocktransactions.physicalstockquantity, 
                stocktransactions.origin, 
                allpartmaster.partdesc, 
                allpartmaster.prodgroup, 
                stockbatches.serialnumber, 
                stockbatches.batchid, 
                stockbatches.classification, 
                CASE 
                                WHEN warehouses.traderid IS NOT NULL 
                                when warehouses.traderid 
                                ELSE stockbatches.traderid 
                END AS generaltraderid, 
                traders.NAME 
FROM            stocktransactions 
LEFT OUTER JOIN stockedparts 
ON              stocktransactions.partid = stockedparts.partid 
INNER JOIN      allpartmaster 
ON              allpartmaster.partnum = stocktransactions.partid 
LEFT OUTER JOIN stockbatches 
ON              stocktransactions.batchnumber = stockbatches.batchnumber 
LEFT OUTER JOIN warehouses 
ON              stockbatches.warehouseid = warehouses.warehouseid 
LEFT OUTER JOIN traders 
ON              ( 
                                warehouses.traderid = traders.id 
                AND             warehouses.tradertype = traders.tradertype) 
OR              ( 
                                stockbatches.traderid = traders.id 
                OR              stockbatches.tradertype = traders.tradertype) 
WHERE           traders.id LIKE '%' 
AND             stocktransactions.partid LIKE '%' 
AND             stocktransactions.warehouseid LIKE '%' 
AND             stocktransactions.reference LIKE '%' 
AND             stocktransactions.source LIKE '%' 
AND             stocktransactions.worksorderid LIKE '%' 
AND             stocktransactions.type LIKE '%' 
AND             stockbatches.serialnumber LIKE '%' 
AND             allpartmaster.prodgroup LIKE '%' 
AND             stocktransactions.batchnumber LIKE '%' 
AND             stockbatches.batchid LIKE '%' 
AND             stockbatches.classification LIKE '% AND stocktransactions.origin LIKE '%' AND stocktransactions.locationid LIKE '%' AND ((stockbatches.consignmenttype IS NOT NULL AND stockbatches.consignmenttype LIKE '%') OR ('%' = 1 AND stockbatches.consignmenttype IS NULL)) AND ('%' = 0 OR (warehouses.isconsignment IS NOT NULL AND warehouses.isconsignment = 1)) AND stocktransactions.referencedate = '%' AND stocktransactions.createddate = '%'

0 个答案:

没有答案