这是为了SI am尝试转换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
WHERE
子句中有CONVERT
。您希望它在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日期格式
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