求一条SQL语句,关于日期的

benniao2 2004-09-20 07:29:57
我想选择所有“日期”字段显示的日期在某个时间之前的纪录,比如2004-5-4 12:00以前,SQL语句怎么写呀?
...全文
170 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
heibai520 2004-09-20
  • 打赏
  • 举报
回复
declare @temp datetime
set @temp='2004-5-4 12:00:00'(你要定的时间)
select * from table where date<@temp
funsuzhou 2004-09-20
  • 打赏
  • 举报
回复
精确到秒:
select * from 表 where cast(cast ('2004-5-4 12:00'as datetime) -日期 as float)>0
xiaoxiangqing 2004-09-20
  • 打赏
  • 举报
回复
select * from tableName where DateCol<'2004-5-4 12:00'
funsuzhou 2004-09-20
  • 打赏
  • 举报
回复
select * from 表 where cast(cast ('2004-5-4'as datetime) -日期 as int) >0
AntingZ 2004-09-20
  • 打赏
  • 举报
回复
select * from 表 where datediff(second,日期字段,'2004-9-15 12:00:00')>0
Andy__Huang 2004-09-20
  • 打赏
  • 举报
回复
declare @dt datetime
set @dt='2004-5-4 12:00:00'
select * from tb where 日期<@dt
gaodongsheng 2004-09-20
  • 打赏
  • 举报
回复
select * from table where col<'2004-5-4'
xuam 2004-09-20
  • 打赏
  • 举报
回复
表结构是什么样的?
benniao2 2004-09-20
  • 打赏
  • 举报
回复
ding

34,873

社区成员

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

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