SQL SERVER 字符转日期函数 与ORACLE 中to_date('12-05-1994', 'dd-mm-yyyy'),等价的sql server 语句是什么?急等,求助。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 set dateformat dmyselect convert(datetime, '12-05-1994') select convert(varchar(10),getdate(),120) select CONVERT(varchar(10),getdate(),120)2004-09-12select CONVERT(varchar, getdate(), 120 )2004-09-12 11:06:08select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')20040912110608select CONVERT(varchar(12) , getdate(), 111 )2004/09/12select CONVERT(varchar(12) , getdate(), 112 )20040912select CONVERT(varchar(12) , getdate(), 102 )2004.09.12其它我不常用的日期格式转换方法:select CONVERT(varchar(12) , getdate(), 101 )09/12/2004select CONVERT(varchar(12) , getdate(), 103 )12/09/2004select CONVERT(varchar(12) , getdate(), 104 )12.09.2004select CONVERT(varchar(12) , getdate(), 105 )12-09-2004select CONVERT(varchar(12) , getdate(), 106 )12 09 2004select CONVERT(varchar(12) , getdate(), 107 )09 12, 2004select CONVERT(varchar(12) , getdate(), 108 )11:06:08select CONVERT(varchar(12) , getdate(), 109 )09 12 2004 1select CONVERT(varchar(12) , getdate(), 110 )09-12-2004select CONVERT(varchar(12) , getdate(), 113 )12 09 2004 1select CONVERT(varchar(12) , getdate(), 114 )11:06:08.177 select convert(varchar(10),getdate(),105)--结果:----------15-08-2009 大家理解错了。我是指把ORACLE 下的to_date('12-05-1994', 'dd-mm-yyyy'),改成SQL server下的语句,如何写呢?就针对这个语句写 select CONVERT(varchar , getdate(), 105 )/*------------------------------15-08-2009(1 行受影响)*/ 不懂oracleORACLE 下的to_date('12-05-1994', 'dd-mm-yyyy')是什么意思?你举个例子,是从把什么转换成什么? declare @s varchar(20)set @s='12-05-1994'select cast(@s as datetime)/*-----------------------1994-12-05 00:00:00.000(1 行受影响)*/declare @s varchar(20)set @s='12-05-1994'select convert(datetime,@s)/*-----------------------1994-12-05 00:00:00.000(1 行受影响)*/ declare @d varchar(10)set @d='12-05-1994' select cast(right(@d,4)+substring(@d,4,2)+left(@d,2) as datetime)/*-----------------------1994-05-12 00:00:00.000(1 行受影响)*/ select *from tb where time字段=convert(datetime,'12-05-1994')? select cast('12-05-1994' as datetime)select convert(datetime,'12-05-1994') 根据具体值, 一部分值可以通过convert, cast, 来替代函数功能等效的话, 在MSSQL是没有的, to_date, 第二个参数太灵活了 问题 解决。方法为:insert into abc(a,b)values ('101',cast('12-5-1994' as datetime ));注意日期是12月5号 我是一个菜鸟!想请教大家一些问题!先谢谢了! 求SQL语句 我想对3个表的内容进行联合查询 请问怎么办? 求一个sql语句 求一简单sql语句 我想用T-SQL打印一个乘法表,怎么打不出啊? 如何取到一条记录中的最大值和最小值,是否有这样的函数,急呀! 数据库无法使用:Failed to reserve contiguous memory of Size= 65536 虚拟机vpc5.2无法安装sql server2000 ACCESS幼稚问题 在sql server2008中怎样设置自动缩进 SQL SERVER 字符转日期函数
set dateformat dmy
select convert(datetime, '12-05-1994')
select convert(varchar(10),getdate(),120)
2004-09-12select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
20040912110608select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12select CONVERT(varchar(12) , getdate(), 112 )
20040912select CONVERT(varchar(12) , getdate(), 102 )
2004.09.12其它我不常用的日期格式转换方法:select CONVERT(varchar(12) , getdate(), 101 )
09/12/2004select CONVERT(varchar(12) , getdate(), 103 )
12/09/2004select CONVERT(varchar(12) , getdate(), 104 )
12.09.2004select CONVERT(varchar(12) , getdate(), 105 )
12-09-2004select CONVERT(varchar(12) , getdate(), 106 )
12 09 2004select CONVERT(varchar(12) , getdate(), 107 )
09 12, 2004select CONVERT(varchar(12) , getdate(), 108 )
11:06:08select CONVERT(varchar(12) , getdate(), 109 )
09 12 2004 1select CONVERT(varchar(12) , getdate(), 110 )
09-12-2004select CONVERT(varchar(12) , getdate(), 113 )
12 09 2004 1select CONVERT(varchar(12) , getdate(), 114 )
11:06:08.177
--结果:
----------
15-08-2009
/*
------------------------------
15-08-2009(1 行受影响)
*/
ORACLE 下的to_date('12-05-1994', 'dd-mm-yyyy')是什么意思?
你举个例子,是从把什么转换成什么?
declare @s varchar(20)
set @s='12-05-1994'
select cast(@s as datetime)/*
-----------------------
1994-12-05 00:00:00.000(1 行受影响)*/declare @s varchar(20)
set @s='12-05-1994'
select convert(datetime,@s)
/*-----------------------
1994-12-05 00:00:00.000(1 行受影响)*/
set @d='12-05-1994' select cast(right(@d,4)+substring(@d,4,2)+left(@d,2) as datetime)
/*
-----------------------
1994-05-12 00:00:00.000(1 行受影响)
*/
from tb
where time字段=convert(datetime,'12-05-1994')?
select convert(datetime,'12-05-1994')
函数功能等效的话, 在MSSQL是没有的, to_date, 第二个参数太灵活了
values ('101',cast('12-5-1994' as datetime ));注意日期是12月5号