易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL 时间查询 - MS-SQL Server / 基础类


表名: date
cbstartdate cbenddate

2010-03-16 12:00:00.000 2010-05-17 17:45:23.000
2010-03-17 12:00:00.000 2010-05-18 23:45:55.000
2010-04-12 12:00:00.000 2010-05-18 23:44:06.000
2010-05-12 12:00:00.000 2010-05-18 23:46:05.000
2010-05-12 12:00:00.000 2010-05-18 23:46:05.000
2010-05-17 17:54:50.560 2010-05-18 23:03:40.000
2010-05-17 17:54:50.560 2010-05-18 23:03:40.000
cbstartdate 起始时间 cbenddate 结束时间
我想要查询 时间在cbstartdate 在2010-05-17 到 cbenddate 2010-05-18 之间的数据


SELECT * from date where cbstartdate>'2010-05-17' and cbenddate<'2010-05-19'

SQL code:
select * from [Table]
where convert(varchar(10),cbstartdate,120)='2010-05-17'
and convert(varchar(10),cbenddate,120)='2010-05-18'


SQL code:
--> 生成测试数据表: [date]
IF OBJECT_ID('[date]') IS NOT NULL
DROP TABLE [date]
GO
CREATE TABLE [date] ([cbstartdate] [datetime],[cbenddate] [datetime])
INSERT INTO [date]
SELECT '2010-03-16 12:00:00.000','2010-05-17 17:45:23.000' UNION ALL
SELECT '2010-03-17 12:00:00.000','2010-05-18 23:45:55.000' UNION ALL
SELECT '2010-04-12 12:00:00.000','2010-05-18 23:44:06.000' UNION ALL
SELECT '2010-05-12 12:00:


相关问答:

数据以xml格式返回 - MS-SQL Server / 应用实例

从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
   <folder state="unchecked&qu ......

求一sql语句 - MS-SQL Server / 疑难问题

现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......

MS SQL作业问题 - MS-SQL Server / 应用实例

如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP

参考:http://hi.baidu.com/toiota ......

求一SQL - MS-SQL Server / 基础类

tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......

关于Vb中sql语句的写法(100分) - Java / Web 开发

求个vb中的sql语句的写法,次sql语句的用法是分页程序
我写的如下:其中A是用来接收每页显示的记录的条数,B是用来接收显示的当前的页面.
sqltext="select top A * from log where id not in(select top ( ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号