select dt from tb1 where dt.senddate || '-01' = '2005-01-01'
select CONVERT (varchar(7),rq, 126) as yf from table2
select * from 表 where 时间>=cast(datepicker1.datetime as datetime) and 时间<=cast(datepicker2.datetime as datetime) 这是sql server2000数据库的,如果不用cast会把日期当作字符,如'>=2005-1-1' and <='2005-11-1'结果中肯定没有10月份的记录!哈哈,这是刚学会就拿来卖了啊!
上面的,楼主应该是没有使用datepicker2控件,是直接用Edit控件输入的字符串来判断。 楼主的意思是要查找出一到二月份的数据,可以这样来实现: select * from 表 where DATEDIFF(month,‘2005-01-01',输入时间)>=0 and DATEDIFF(month,‘2005-02-01',输入时间)<=0
上面的楼主,如果我在wwdbdatetimepicker里输入的时间格式是2005-01,那我的查询语句用你写的这句,select * from 表 where DATEDIFF(month,‘2005-01-01',输入时间)>=0 and DATEDIFF(month,‘2005-02-01',输入时间)<=0,应该没问题吧
这是sql server2000数据库的,如果不用cast会把日期当作字符,如'>=2005-1-1' and <='2005-11-1'结果中肯定没有10月份的记录!哈哈,这是刚学会就拿来卖了啊!
楼主的意思是要查找出一到二月份的数据,可以这样来实现:
select * from 表 where DATEDIFF(month,‘2005-01-01',输入时间)>=0
and DATEDIFF(month,‘2005-02-01',输入时间)<=0
and DATEDIFF(month,‘2005-02-01',输入时间)<=0,应该没问题吧
见意用CONVERT (varchar(7),日期, 126),取出的格式为: 2005-08
convert(char(7),日期,12) >= '2005-01'
and convert(char(7),日期,12) <= '2005-02'