惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Blog — PlanetScale
Blog — PlanetScale
小众软件
小众软件
F
Fortinet All Blogs
博客园 - 叶小钗
博客园_首页
D
DataBreaches.Net
Apple Machine Learning Research
Apple Machine Learning Research
U
Unit 42
爱范儿
爱范儿
aimingoo的专栏
aimingoo的专栏
博客园 - Franky
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
The Cloudflare Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
IT之家
IT之家
M
MIT News - Artificial intelligence
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog

博客园 - 中国土匪

OpenSocial容器开发,资料备注 列出数据库中有数据的表的全部数据 比较两个数据库之间差异的存储过程 关于Web Application中的类无法在页面中引用的问题 图形字符名称表(备查) 决心--重新拾起技术! BitComet的IE插件BitCommet Helper可能给系统造成错误的巨大Bug!!!求解决方案 Page事件发生的先后顺序 操作IIS过程中碰到的问题总结 在 ASP.NET 中使用计时器(Timer) (转载) 当了3个礼拜老师感想 给CheckboxList分页 关于ItemCommand事件 (转自混沌居) 在.net1.1中发送邮件的几种办法 常用正则表达式总结 datalist分页方式汇总(更新了一种方法) membership.findusersbyname模糊匹配的写法 用BitComet的奇怪问题 装了红帽子9了
MSSql Datetime转换成char 的样式汇总
中国土匪 · 2010-04-12 · via 博客园 - 中国土匪

select 1,convert(nvarchar,getdate(),1)
union select 2,convert(nvarchar,getdate(),2)
union select 3,convert(nvarchar,getdate(),3)
union select 4,convert(nvarchar,getdate(),4)
union select 5,convert(nvarchar,getdate(),5)
union select 6,convert(nvarchar,getdate(),6)
union select 7,convert(nvarchar,getdate(),7)
union select 8,convert(nvarchar,getdate(),8)
union select 9,convert(nvarchar,getdate(),9)
union select 10,convert(nvarchar,getdate(),10)
union select 11,convert(nvarchar,getdate(),11)
union select 12,convert(nvarchar,getdate(),12)
union select 13,convert(nvarchar,getdate(),13)
union select 14,convert(nvarchar,getdate(),14)
union select 20,convert(nvarchar,getdate(),20)
union select 21,convert(nvarchar,getdate(),21)
union select 22,convert(nvarchar,getdate(),22)
union select 23,convert(nvarchar,getdate(),23)
union select 24,convert(nvarchar,getdate(),24)
union select 25,convert(nvarchar,getdate(),25)

执行结果:

类型值 转换结果
1 03/22/10
2 10.03.22
3 22/03/10
4 22.03.10
5 22-03-10
6 22 03 10
7 03 22, 10
8 10:42:54
9 03 22 2010 10:42:54:777AM
10 03-22-10
11 10/03/22
12 100322
13 22 03 2010 10:42:54:777
14 10:42:54:777
20 2010-03-22 10:42:54
21 2010-03-22 10:42:54.777
22 03/22/10 10:42:54 AM
23 2010-03-22
24 10:42:54
25 2010-03-22 10:42:54.777

 特殊情况:

1 转换为“YYMMDDHHmmss”格式

 1 declare @now as char(19);
 2 declare @year as char(2);
 3 declare @month as char(2);
 4 declare @day as char(2);
 5 declare @hour as char(2);
 6 declare @minute as char(2);
 7 declare @second as char(2);
 8 declare @YYMMDDHHmmss as char(12);
 9 set @now = convert(char,getdate(),20);
10 set @year = substring(@now,3,2);
11 set @month = substring(@now,6,2);
12 set @day = substring(@now,9,2);
13 set @hour = substring(@now,12,2);
14 set @minute = substring(@now,15,2);
15 set @second = substring(@now,18,2);
16 set @YYMMDDHHmmss = @year+@month+@day+@hour+@minute+@second