`

Sybase 时间处理Convert 的使用

阅读更多

1.Sybase SQL 脚本 DDL 定义脚本

 

create table rpt_spvoicenaviuser (
	begintime                       varchar(19)                      not null  ,
	endtime                         varchar(19)                      not null  ,
	stattype                        int                              not null  ,
	booknum                         int                              not null  ,
	cancelnum                       int                              not null  ,
	totalnum                        int                              not null   
)
lock allpages
 on 'default'
go 


setuser
go 

 2.问题因为底层是字符串所以要双方都做处理

  语句如

写法一
SELECT * FROM rpt_spvoicenaviuser 
WHERE convert(datetime,begintime) >= convert(datetime,'2010-10-4')

写法二
SELECT * FROM rpt_spvoicenaviuser
WHERE CONVERT(DATETIME,begintime) >= CONVERT(DATETIME,'2010-7-2 00:00:00') 
AND CONVERT(DATETIME,endtime) <= CONVERT(DATETIME,'2010-7-4 23:59:59')  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics