数据库中有哪几种date类型的格式?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据库中有哪几种date类型的格式?相关的知识,希望对你有一定的参考价值。

在数据库取出来的时候就转换好
select
getdate()
2006-05-12
11:06:08.177
我整理了一下SQL
Server里面可能经常会用到的日期格式转换方法:
举例如下:
select
Convert(varchar(10),getdate(),120)
2006-05-12
select
CONVERT(varchar,
getdate(),
120
)
2006-05-12
11:06:08
select
replace(replace(replace(CONVERT(varchar,
getdate(),
120
),'-',''),'
',''),':','')
20060512110608
select
CONVERT(varchar(12)
,
getdate(),
111
)
2006/05/12
select
CONVERT(varchar(12)
,
getdate(),
112
)
20060512
select
CONVERT(varchar(12)
,
getdate(),
102
)
2006.05.12
其它几种不常用的日期格式转换方法:
select
CONVERT(varchar(12)
,
getdate(),
101
)
0612/2005
select
CONVERT(varchar(12)
,
getdate(),
103
)
12/09/2004
select
CONVERT(varchar(12)
,
getdate(),
104
)
12.05.2006
select
CONVERT(varchar(12)
,
getdate(),
105
)
12-05-2006
select
CONVERT(varchar(12)
,
getdate(),
106
)
12
05
2006
select
CONVERT(varchar(12)
,
getdate(),
107
)
05
12,
2006
select
CONVERT(varchar(12)
,
getdate(),
108
)
11:06:08
select
CONVERT(varchar(12)
,
getdate(),
109
)
0512
2006
1
select
CONVERT(varchar(12)
,
getdate(),
110
)
09-12-2004
select
CONVERT(varchar(12)
,
getdate(),
113
)
12
052006
select
CONVERT(varchar(12)
,
getdate(),
114
)
11:06:08.177
参考技术A 日期格式有还几种,有比较精确一点的时间,也初象一点的,一般有,拿2006年5月12号为例来说吧,它可以为
2006-05-12
11:06:08
2006-05-12
20060512110608
20060512
2006/05/12
05-12-2006

以上是关于数据库中有哪几种date类型的格式?的主要内容,如果未能解决你的问题,请参考以下文章

jQuery的$.ajax方法响应数据类型有哪几种?本质上原生ajax响应数据格式有哪几种,分别对应哪个属性?

在c语言中数据类型转换主要有哪几种方式

js的数据类型有哪几种

jquery中有哪几种类型的选择器?

verilog中有哪几种类型的赋值语句,说明它们的区别,并举例

jquery中有哪几种类型的选择器