以下查询提供此错误
The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.
字段timedate在数据库中看起来像这个13/11/2012 uk格式。
任何人都知道如何解决这个问题。
SELECT
PRODID, ITEMDES, QTY, StockCode,shipName, shipCompany, shipAddress1, shipAddress2, shipAddress3,shipPostCode,shipcity,shipCountry,shipCounty,customerMessage
FROM orderedItems oi
left join orders o on oi.order_id = o.order_id
where( CONVERT(nvarchar(30),timedate,120) >=
<cfqueryparam cfsqltype="cf_sql_date" value="#LSDateFormat(form.fromDate, "yyyy-mm-dd")# 00:00:00">
AND CONVERT(nvarchar(30),timedate,120) <=
<cfqueryparam cfsqltype="cf_sql_date" value="#LSDateFormat(FORM.toDate, "yyyy-mm-dd")# 23:59:59">
)
Group by PRODID,ITEMDES,QTY, StockCode,shipName, shipCompany, shipAddress1, shipAddress2, shipAddress3,shipPostCode,shipcity,shipCountry,shipCounty,customerMessage
ORDER BY PRODID
答案 0 :(得分:1)
我认为sql-server可能会将您的日期解释为美国格式,即mm/dd/YYYY
,显然没有第13个月,因此超出范围错误。
您可能更适合使用正确的字段类型保存日期。