我在下面的代码中有问题任何身体可以帮助我吗? 它的显示(DATEDIFE'不是公认的内置函数名。)错误
com.CommandText = "select DATEDIFE(year,'2008-06-05','2010-06-05') AS XXX";
da = new SqlDataAdapter(com);
dt = new DataTable();
da.Fill(dt);
最诚挚的问候 阿里
答案 0 :(得分:2)
你有一个错字,Datedife - > DATEDIFF。尝试:
select Datediff(year,'2008-06-05','2010-06-05') AS XXX
答案 1 :(得分:1)
其DATEDIFF
com.CommandText = "select DATEDIFF(year,'2008-06-05','2010-06-05') AS XXX";
da = new SqlDataAdapter(com);
dt = new DataTable();
da.Fill(dt);
答案 2 :(得分:0)
使用DATEDIFF
com.CommandText = "select DATEDIFF(year,'2008-06-05','2010-06-05') AS XXX";
答案 3 :(得分:0)
使用DATEDIFF(而不是DATEDIFE,它是一个错误的关键字)
您的查询中存在拼写错误
SELECT DATEDIFF(YEAR,'2008-06-05','2010-06-05') AS XXX