create proc  ppp
@month   int
as select *  from table
where ArrivalDateTime in (这里该怎么写条件,把输入的月份转换成当月?)

解决方案 »

  1.   

    select *  from table 
    where datepart(month,ArrivalDateTime) =@month  
      

  2.   


    create proc  ppp
    @month  int
    asselect *  from table
    where Month(ArrivalDateTime)=@month
      

  3.   

    最好加上年份
    create proc  ppp 
    @year int,
    @month  int 
    as select *  from ta 
    where datepart(year,ArrivalDateTime) =@year  and
    datepart(month,ArrivalDateTime) =@month  
      

  4.   

    create proc  ppp 
    @month  int 
    as select *  from table 
    where datepart(mm,ArrivalDateTime)=@month 
      

  5.   

    create proc  ppp (@month  int)
    as 
    begin
    select *  from table 
    where convert(char(6),ArrivalDateTime,112)='@month'
    --不知道ArrivalDateTime是什么格式的?上面convert(char(6),ArrivalDateTime,112)是取年月
    end
    ....
    exec ppp '200811'