0

这是因为 SI 正在尝试转换 DATETIME,因此它的格式为“mm/dd/yy”

我需要“LastPaymnt_Date”大于或等于 31 - 我已在下面成功设置。任何帮助,将不胜感激

这就是我所拥有的;它会生成“CONVERT 附近的语法不正确”错误

SELECT D1_Name AS 'Debtor Name', FILENO, Balance, LPaymnt_Date AS 'Last Payment Date'
FROM MASTER
WHERE LPaymnt_Date>=GETDATE()-31 
CONVERT(varchar(20), GETDATE, 101
AND(Forw_no>= 340 AND Forw_no <=348)
OR Forw_no =831
ORDER BY D1_Name
4

2 回答 2

1
SELECT D1_Name AS 'Debtor Name', FILENO, Balance, 
       LPaymnt_Date AS 'Last Payment Date',
       CONVERT(varchar(20), GETDATE(), 101) As FormattedDate
FROM MASTER
WHERE LPaymnt_Date >= GETDATE()-31 
 AND ((Forw_no>= 340 AND Forw_no <=348) OR Forw_no =831))
ORDER BY D1_Name
于 2013-02-18T17:00:47.073 回答
1

你有CONVERTinWHERE子句。你想要它在SELECT

SELECT D1_Name AS 'Debtor Name', FILENO, Balance, 
       CONVERT(VARCHAR(10), LPaymnt_Date, 101) AS 'Last Payment Date'
FROM MASTER
WHERE LPaymnt_Date>=GETDATE()-31 
AND(Forw_no>= 340 AND Forw_no <=348)
OR Forw_no =831
ORDER BY D1_Name

有关更多信息,请参见此处: SQL Server 日期格式

于 2013-02-18T17:01:16.037 回答