简体   繁体   中英

'DATEDIFE' is not a recognized built-in function name

i have problem in below code any body can help me? it's shows (DATEDIFE' is not a recognized built-in function name.) Error

        com.CommandText = "select DATEDIFE(year,'2008-06-05','2010-06-05') AS XXX";

        da = new SqlDataAdapter(com);
        dt = new DataTable();
        da.Fill(dt);

Best Regards Alireza

You have a typo, Datedife -> Datediff. Try:

select Datediff(year,'2008-06-05','2010-06-05') AS XXX

Its DATEDIFF

 com.CommandText = "select DATEDIFF(year,'2008-06-05','2010-06-05') AS XXX";

        da = new SqlDataAdapter(com);
        dt = new DataTable();
        da.Fill(dt);

使用DATEDIFF

com.CommandText = "select DATEDIFF(year,'2008-06-05','2010-06-05') AS XXX";

use DATEDIFF(instead of DATEDIFE its a wrong keyword)

There is a spelling mistake in your query

SELECT DATEDIFF(YEAR,'2008-06-05','2010-06-05') AS XXX

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM