找到2个日期之间的范围后,“12”运算符错误后缺少操作数

时间:2015-06-07 03:24:03

标签: c# ado.net

执行以下代码时,我收到错误“'12'运算符后缺少操作数”。

employee.Select(Table.Key + " = '" + dept.Key.ToString() + "' AND " +  Table.EnteredDate + "BETWEEN" + startDate + "AND" + endDate)))

2 个答案:

答案 0 :(得分:0)

employee.Select(Table.Key + " = '" + dept.Key.ToString() + "' AND '" +  Table.EnteredDate.ToString("yyyyMMdd") + "' BETWEEN '" + startDate.ToString("yyyyMMdd") + "' AND '" + endDate.ToString("yyyyMMdd") + "'")))

希望它有效。你的意见不足。

答案 1 :(得分:0)

以下代码有效!

employee.Select(Table.Key + " = '" + dept.Key.ToString() + "' AND " + Table.EnteredDate + " >= '" + startDate.ToString("yyyyMMdd") + "' AND " + Table.EnteredDate + " <= '" + endDate.Value.ToString("dd/MM/yyyy");