我正在尝试使用以下代码获取上个月的数据,但不断收到以下错误:
数据异常 - 参数必须为DATE或DATETIME
这是我的代码:
SELECT cast(OPEN_DATE as datetime)
FROM OPENQUERY(serverb,' SELECT cast(OPEN_DATE as datetime)
FROM xx
WHERE co_cde = 15
and cust_no in (1780066)
and cast(OPEN_DATE as datetime) >=
DATEADD(mm,DATEDIFF(mm,0,GETDATE())-1,0)
AND cast(OPEN_DATE as datetime) <
DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0) ' )