有一个字段是 varchar型,字段里面存的是2003-6-9 8:00:00这样的数据.

renren6250 2003-08-20 01:37:36
有一个字段是 varchar型,字段里面存的是2003-6-9 8:00:00
或者是 2003-8-3这样的数据.
如下:表里这样的数据:
2003-6-9 8:00:00
2003-6-2
2003-6-12 10:02:13
2003-6-9 9:23:04
2003-6-11
我通过什么样的查询能得出如下数据
2003-6-12 10:02:13
2003-6-9 9:23:04
2003-6-11
也就是两个时间端的内容,谢谢大家
...全文
113 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjcxc 元老 2003-08-20
  • 打赏
  • 举报
回复
两个时间段之间的记录,用convert进行数据类型转换就行了.

select * from 表 where cast(字段 as datetime) between '2003-06-09' and '2003-6-12 10:02:13'
zjcxc 元老 2003-08-20
  • 打赏
  • 举报
回复
select * from 表 where 字段 in('2003-6-12 10:02:13','2003-6-9 9:23:04','2003-6-11')
hjb111 2003-08-20
  • 打赏
  • 举报
回复
select * from yourtable where cast( 字段 as datetime) between '2003-6-9 9:23:04' and '2003-6-12 10:02:13'
happydreamer 2003-08-20
  • 打赏
  • 举报
回复
where cast( 字段 as datetime) between '2003-6-9 9:23:04' and '2003-6-12 10:02:13'
happydreamer 2003-08-20
  • 打赏
  • 举报
回复
where cast( 字段 as datetime) between '2003-6-9 9:23:04' and '2003-6-12 10:02:13'
happydreamer 2003-08-20
  • 打赏
  • 举报
回复
where cast( 字段 as datetime) between '2003-6-9 9:23:04' and '2003-6-12 10:02:13'
amtyuranus 2003-08-20
  • 打赏
  • 举报
回复
select * from table where convert(col,datetime,130) >'shijian' and convert(col,datetime,130) <'shijian'
hugeforest 2003-08-20
  • 打赏
  • 举报
回复
select * from table where cast(字段 as datetime) >= '2003-6-9 9:23:04'
愉快的登山者 2003-08-20
  • 打赏
  • 举报
回复
select * from yourtable where col between '2003-6-9 9:23:04' and '2003-6-12 10:02:13'

愉快的登山者


◢◣◢◣◢◣
pengdali 2003-08-20
  • 打赏
  • 举报
回复
select * from 表 where cast(字段 as datetime) between '开始时间' and '结束时间'
CrazyFor 2003-08-20
  • 打赏
  • 举报
回复
不明白怎么分时间端!!`

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧