年份为当前行的行数

时间:2018-03-16 15:26:41

标签: c# sql-server-ce

我试图在SQL Server Compact中运行此查询

SqlCeCommand saldo = new SqlCeCommand("select count(*) from objetos where year(datarececao) = getdate()", con);
Int32 count5 = (Int32)saldo.ExecuteScalar();
label16.Text = Convert.ToString(count5);

但是因为这是一个SQL / MySQL查询,我得到一个错误,SQLCE无法识别该函数

我该怎么做?感谢

1 个答案:

答案 0 :(得分:2)

试试这个:

SELECT COUNT(*)
from objetos 
where DATEPART(year, datarececao) = DATEPART(year, GETDATE())