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

sql 日期转换! - .NET技术 / ASP.NET

由于前期设计问题 现在 有列 string 类型 2009-9-9 0:00:00 2009年9月9日 2009-9-9 2009-9-9 0:00
这四种格式 现在想查某段时间类的数据 这列该怎么转换 convert( datetime , a) or cast(a as datetime )

好像怎么转换都成了1900-01-01 00:00:00.000
?????????
string.Format()
用这个定下格式

引用
string.Format()
用这个定下格式
哥们 我说是在sql里

declare @a varchar(22)
set @a='2009-9-9 0:00:00'
select cast(replace(@a ,':',':') as datetime )

set @a='2009年9月9日'
select cast(replace(replace(replace(@a ,'年','-'),'月','-'),'日',' ') as datetime )

试试上面 sql

http://www.mystruggle.com.cn

SQL code:

select * from testDate where cast(replace(replace(replace(now,'日',''),'月','-'),'年','-') as datetime)>cast('2009-9-9' as datetime);


实验成功了

把那个now替换成,你的那个日期字段

使用between and查询

引用
declare @a varchar(22)
set @a='2009-9-9 0:00:00'
select cast(replace(@a ,':',':') as datetime )

set @a='2009年9月9日'
select cast(replace(replace(replace(@a ,'年','-'),'月','-'),'日',' ') as datetime ……


正解


引用
SQL code

create


相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

sql小小的疑问 - .NET技术 / C#

可能因为工作的原因 接触数据库这块比较少,之前都是做程序这块,数据库这块都有专门的人来做 分工都很明细 所以对数据库这一块完全不了解。前段时间 去面试了几家公司 几乎都是在数据库这块挂掉的 连个简单的SQ ......

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

tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号