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

sqlserver数据库DateTime格式操作

数据里(sqlserver) 的操作 :
eg :2008-3-31 10:34 --> 2008-3-31
一.截取字符串方式
select substring('2008-3-31 10:34',0,charindex(' ','2008-3-31 10:34'))
二.
Select
CONVERT(varchar, getdate(), 1),--mm/dd/yy
CONVERT(varchar, getdate(), 2),--yy.mm.dd
CONVERT(varchar, getdate(), 3),--dd/mm/yy
CONVERT(varchar, getdate(), 4),--dd.mm.yy
CONVERT(varchar, getdate(), 5),--dd-mm-yy
CONVERT(varchar, getdate(), 10),--mm-dd-yy
CONVERT(varchar, getdate(), 11),--yy/mm/dd
CONVERT(varchar, getdate(), 12)--yymmdd
----带世纪号
select convert(varchar(10),getdate(),100) --06 15 2007 或0
select convert(varchar(10),getdate(),102) --2007.06.15
select convert(varchar(10),getdate(),103) --15/06/2007
select convert(varchar(10),getdate(),104) --15.06.2007s
select convert(varchar(10),getdate(),105) --15-06-2007
select convert(varchar(10),getdate(),106) --15 06 2007
select convert(varchar(10),getdate(),107) --06-15,200
select convert(varchar(10),getdate(),108) --10:06:46 当前时间
select convert(varchar(10),getdate(),109) --06 15 2007 或者9
select convert(varchar(10),getdate(),110) --06-15-2007
select convert(varchar(10),getdate(),111) --2007/06/15
select convert(varchar(10),getdate(),112) --20070615
select convert(varchar(10),getdate(),113) --15 06 2007 或者13
select convert(varchar(10),getdate(),114) --10:10:37:0
select convert(varchar(10),getdate(),120) --2007-06-15 或20---------------<OK>
select convert(varchar(30),getdate(),121) --2007-06-15 10:11:45.040 或21
select convert(varchar(30),getdate(),126) --2007-06-15T10:12:44:603
select convert(varchar(50),getdate(),127) --2007-06-15T10:14:35:433 说带时区
select convert(varchar(40),getdate(),130) --回历dd mon yyyy hh:mi:ss:mmmAM
select convert(varchar(30),getdate(),131) --30/05/1428 10:17:19:470AM
GO

三.非 sqlserver 数据库
//可用使用
data(db_field)
相关链接:http://hi.baidu.com/bbsl166/blog/item/d9ebd4fafb005417a9d31110.html


相关文档:

Spring配置的MS SQLSERVER 2008 JDBC连接


  不得不说的在 MS SQL SERVER 下的 JDBC 调用
 
今天下午,临时决定要再 MS SQL-SERVER  下配置 Spring 的数据源 DataSource 。但配置了半天,获取数据源仍不成功,我没有办法,找原因呗,只能写个列子测试下。先不管三七二十一,先上正确的例子再说。
看客如果想运行下面的代码,需要自己手工 ......

SQLServer 表查询中的 合并查询 合集 差集 交集

use tempdb
go
if (object_id ('t1' ) is not null ) drop table t1
if (object_id ('t2' ) is not null ) drop table t2
go
create table t1 (a int )
insert into t1 select 1 union select 2 union select 3
create table t2 (a int )
insert into t2 select 3 union select 4 union select 5
go
sele ......

学习:两种SqlServer数据库连接的示例代码

1、实例一:
public void SqlConnectionOpen()
{
        SqlConnection myConn=new SqlConnection();
        myConn.ConnectionString="server=(local);database=pubs;Trusted_Connection=yes";
        ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号