社区
MS-SQL Server
帖子详情
新手请教:SQLserver中有一datetime字段selldate不知用什么函数能取出他的时间,convert(varchar(10),selldate,102)怎么什么记录也查不到??
ssd
2001-12-17 04:22:24
select * from table1 where convert(varchar(10),selldate,102)='2001-12-12'
怎么什么记录也查不到
...全文
161
5
打赏
收藏
新手请教:SQLserver中有一datetime字段selldate不知用什么函数能取出他的时间,convert(varchar(10),selldate,102)怎么什么记录也查不到??
select * from table1 where convert(varchar(10),selldate,102)='2001-12-12' 怎么什么记录也查不到
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
5 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
netcar
2001-12-17
打赏
举报
回复
将操作系统的短日期格式设置为yyyy-M-d或者yyyy-MM-dd
蓝天
2001-12-17
打赏
举报
回复
select * from table where year(selldate)=2001 and month(selldate)=12 and day(selldate)=12
Rayking
2001-12-17
打赏
举报
回复
select selldate-cast(selldate-0.5 as int) as 你要的时间 from table1
三杯倒
2001-12-17
打赏
举报
回复
应该把'2001-12-12',转换成date型比较
select * from table1 where convert(varchar(10),selldate,102)='2001-12-12'
如果selldate为索引,此索引将不起任何意义
kanghl
2001-12-17
打赏
举报
回复
select * from table1 where convert(char(10),selldate,102)='2001.12.12'
select * from table1 where convert(char(10),selldate,111)='2001/12/12'
6、SQL Server:
SqlServer
时间
日期处理
函数
及字符串转换
本文来自:http://blog.sina.com.cn/s/blog_634c33eb0
10
1859v.html Sql Server中的日期与
时间
函数
1. 当前系统日期、
时间
sel
ect getda
te
() 2. da
te
add 在向指定日期加上一段
时间
的基础上,返回新的
da
te
time
值 例如:向日期加上2天
sel
ect dat
SQL Server取系统当前
时间
getda
te
//获得系统当前日期 da
te
part //获取日期指定部分(年月日时分表) getda
te
()
函数
:取得系统当前的日期和
时间
。返回值为
da
te
time
类型的。 用法:getda
te
() 例子:
sel
ect getda
te
() as d
te
,da
te
add(day,-1,getda
te
()) as nowdat 输出结果: d
te
nowdat ------
SQL Server取系统当前
时间
,增减
时间
getda
te
//获得系统当前日期 da
te
part //获取日期指定部分(年月日时分表) getda
te
()
函数
:取得系统当前的日期和
时间
。返回值为
da
te
time
类型的。 用法:getda
te
() 例子:
sel
ect getda
te
() as d
te
,da
te
add(day,-1,getda
te
()) as nowdat 输出结果: d
te
nowdat ------...
SQL Server习题及答案6
一、单选题(共
10
道试题,共 50 分。) SQL Server中,保存着每个数据库对象的信息的系统表是( C)。 A. sysdatabases B. Syscolumns C. Sysobjects D. Syslogs 在存在下列关键字的SQL语句中,不可能出现Where子句的是(D )。 A. Upda
te
B. Dele
te
C. Insert D. Al
te
r 在查询语句的Where子句中,如果出现了“age Between 30 and 40”,这个表达式等同于(A )。 A. age&
Sql 中CAST和
CONVERT
的区别
将一种数据类型的表达式转换为另一种数据类型的表达式。 CAST语法: CAST ( expression AS data_type [ (length ) ])
CONVERT
语法:
CONVERT
( data_type [ ( length ) ] , expression [ , style ] ) 参数 expression ...
MS-SQL Server
34,837
社区成员
254,632
社区内容
发帖
与我相关
我的任务
MS-SQL Server
MS-SQL Server相关内容讨论专区
复制链接
扫一扫
分享
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章