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

sql语句 截取时间 只显示 年,月,日的格式


摘自http://blog.sina.com.cn/zhm85
SQL语句截取时间,只显示年月日(2004-09-12)
select CONVERT(varchar, getdate(), 120 )
‘getdate()’改为时间字段名‘createtime’
再重命名新加列(Select Name AS UName from Users)
例如 select convert(varchar(11),createtime,120) as Ndate from UserS
日期截取显示格式
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),\'-\',\'\'),\' \',\'\'),\':\',\'\')
20040912110608
select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )
20040912
select CONVERT(varchar(12) , getdate(), 102 )
2004.09.12
select CONVERT(varchar(12) , getdate(), 101 )
09/12/2004
select CONVERT(varchar(12) , getdate(), 103 )
12/09/2004
select CONVERT(varchar(12) , getdate(), 104 )
12.09.2004
select CONVERT(varchar(12) , getdate(), 105 )
12-09-2004
select CONVERT(varchar(12) , getdate(), 106 )
12 09 2004
select CONVERT(varchar(12) , getdate(), 107 )
09 12, 2004
select CONVERT(varchar(12) , getdate(), 108 )
11:06:08
select CONVERT(varchar(12) , getdate(), 109 )
09 12 2004 1
select CONVERT(varchar(12) , getdate(), 110 )
09-12-2004
select CONVERT(varchar(12) , getdate(), 113 )
12 09 2004 1
select CONVERT(varchar(12) , getdate(), 114 )
11:06:08.177


相关文档:

使用SQLServer模板来写规范的SQL语句

如果你经常遇到下面的问题,你就要考虑使用SQL Server的模板来写规范的SQL语句了:
SQL初学者。
经常忘记常用的DML或是DDL SQL 语句。
在多人开发维护的SQL中,每个人都有自己的SQL习惯,没有一套统一的规范。
在SQL Server Management Studio中,已经给大家提供了很多常用的现成SQL规范模板。
SQL Server Management ......

EXCEL数据导入SQL 的另类用法

做开发过程中,经常会用到将Excel中数据导出到SQL Server中的情况,你可以利用SQL SERVER 中自带的导入数据的方式,但这种方式,有时会发现数据导入后,可能为空,可能开头少个零,此种情况多出现于数值型的列,今天在CSDN上闲逛,偶尔发现了一个帖子,介绍的以下这种方法,本人恰七因最近公司准备上市,审计局在做审计,技 ......

SQL数据库

1.      存储过程(定义&编写)
l  创建存储过程
CREATE PROCEDURE storedproc1
AS
SELECT *
from tb_project
WHERE  预计工期<= 90
ORDER BY  预计工期 DESC
GO
exec storedproc1
GO
 
l   修改存储过程
ALTER PROCEDURE storedproc1
AS
SEL ......

一个sql简单函数实现拼接字符串

--测试数据
create table table1(AID int,NAME nvarchar(20))
create table table2 (BID int,NUMBER nvarchar(20))
insert into table1 select 1,'Tom' union all
select 2,'Jim'
insert into table2 select 1,20 union all
select 1,30
--函数
create function F_Str(@ID int)
returns nvarchar(100)
as
begin ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号