borth是datetime类型吗?不是的话先转换。
select * from vote where datepart(mm,convert(datetime,borth))=12

解决方案 »

  1.   

    kao,够低级的,原来borth是varchar
      

  2.   

    select * from vote where datepart(mm,convert(datetime,borth))=12
      

  3.   

    还是不行啊,我在SQL查询分析器里面可以,怎么在asp里面就又是这样报错了呢?!
      

  4.   

    select month(字段名) from table
      

  5.   

    虽然borth是varchar,但里面的值都是日期格式的啊如:1955-12-27,
    我在SQL里面
    select borth from vote where datepart(mm,convert(datetime,borth))=12没问题,但在ASP里面就报错了?郁闷
      

  6.   

    select borth from vote where datepart(mm,convert(datetime,borth))=12
    這樣寫不會有錯呀,如果borth是char的
      

  7.   

    select * from vote where datepart('mm',convert(datetime,borth))=12
      

  8.   

    select borth from vote where datepart(mm,convert(datetime,borth))=12
    我用这个在SQL查询分析器里面发现查询结果的最后也有错误报告Server: Msg 8115, Level 16, State 2, Line 1
    Arithmetic overflow error converting expression to data type datetime.请问有比较严谨的语句吗?!
      

  9.   

    select borth from vote where substring (borth,6,2)=12
      

  10.   

    select borth from vote where substring (borth,6,2)='12'
      

  11.   

    或者
    select borth from vote where borth like '_____12%'