【网络收集】Sql Server datetime 常用日期格式转换
CONVERT(varchar(10) , sfrq, 21 )
我们经常出于某种目的需要使用各种各样的日期格式,当然我们可以使用字符串操作来构造各种日期格式,但是有现成的函数为什么不用呢? SQL Server中文版的默认的日期字段datetime格式是yyyy-mm-dd Thh:mm:ss.mmm 例如: select getdate() 2016-09-12 11:06:08.177 整理了一下SQL Server里面可能经常会用到的日期格式转换方法: 举例如下: select CONVERT(varchar, getdate(), 120 )
2016-09-12 11:06:08 select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
20160912110608 select CONVERT(varchar(12) , getdate(), 111 )
2016/09/12 select CONVERT(varchar(12) , getdate(), 112 )
20160912 select CONVERT(varchar(12) , getdate(), 102 )
2016.09.12 select CONVERT(varchar(12) , getdate(), 101 )
09/12/2016 select CONVERT(varchar(12) , getdate(), 103 )
12/09/2016 select CONVERT(varchar(12) , getdate(), 104 )
12.09.2016 select CONVERT(varchar(12) , getdate(), 105 )
12-09-2016 select CONVERT(varchar(12) , getdate(), 106 )
12 09 2016 select CONVERT(varchar(12) , getdate(), 107 )
09 12, 2016 select CONVERT(varchar(12) , getdate(), 108 )
11:06:08 select CONVERT(varchar(12) , getdate(), 109 )
09 12 2016 1 select CONVERT(varchar(12) , getdate(), 110 )
09-12-2016 select CONVERT(varchar(12) , getdate(), 113 )
12 09 2016 1 select CONVERT(varchar(12) , getdate(), 114 )
11:06:08.177
帮助文档中的信息
|
Without century (yy) |
With century (yyyy) |
Standard |
Input/Output** |
|
- |
0 or 100 (*) |
Default |
mon dd yyyy hh:miAM (or PM) |
|
1 |
101 |
USA |
mm/dd/yy |
|
2 |
102 |
ANSI |
yy.mm.dd |
|
3 |
103 |
British/French |
dd/mm/yy |
|
4 |
104 |
German |
dd.mm.yy |
|
5 |
105 |
Italian |
dd-mm-yy |
|
6 |
106 |
- |
dd mon yy |
|
7 |
107 |
- |
Mon dd, yy |
|
8 |
108 |
- |
hh:mm:ss |
|
- |
9 or 109 (*) |
Default + milliseconds |
mon dd yyyy hh:mi:ss:mmmAM (or PM) |
|
10 |
110 |
USA |
mm-dd-yy |
|
11 |
111 |
JAPAN |
yy/mm/dd |
|
12 |
112 |
ISO |
yymmdd |
|
- |
13 or 113 (*) |
Europe default + milliseconds |
dd mon yyyy hh:mm:ss:mmm(24h) |
|
14 |
114 |
- |
hh:mi:ss:mmm(24h) |
|
- |
20 or 120 (*) |
ODBC canonical |
yyyy-mm-dd hh:mi:ss(24h) |
|
- |
21 or 121 (*) |
ODBC canonical (with milliseconds) |
yyyy-mm-dd hh:mi:ss.mmm(24h) |
|
- |
126(***) |
ISO8601 |
yyyy-mm-dd Thh:mm:ss:mmm(no spaces) |
|
- |
130* |
Kuwaiti |
dd mon yyyy hh:mi:ss:mmmAM |
|
- |
131* |
Kuwaiti |
dd/mm/yy hh:mi:ss:mmmAM |
【网络收集】Sql Server datetime 常用日期格式转换的更多相关文章
- SQL 将非标准日期格式转换成标准格式,进行条件判断
a.JLDate为非标准日期格式: 例: 2011-8-28 0:00:000011-8-28 0:00:000111-8-4 0:00:00 select CONVERT(varchar(50),C ...
- Sql与C#中日期格式转换总结
SQL中的转换方法: 一.将string转换为datetime,主要是使用Convert方法, 方法,Convert(datetime [ ( length ) ] , expression, [st ...
- Hive常用日期格式转换
固定日期转换成时间戳 select unix_timestamp('2016-08-16','yyyy-MM-dd') --1471276800 select unix_timestamp('2016 ...
- hive 常用日期格式转换
固定日期转换成时间戳select unix_timestamp('2016-08-16','yyyy-MM-dd') --1471276800select unix_timestamp('201608 ...
- SQL Server case when 日期字符串转换 多表查询 嵌套子查询
select distinct stu.*, dbo.GetClassNameByStudentCode(stu.Code) as ClassName, dbo.GetCourseNameByStud ...
- SQL SERVER 字符串类型varchar格式转换成int类型进行排序
日常数据分析过程中,经常会遇到排序的情况,有时会根据空字段表进行临时排序,转换数据类型 使用 ORDER BY CAST (<字段名> AS INT) ASC 举例: SELECT I ...
- 在SQL Server中 获取日期、日期格式转换
--常用日期转换参数: PRINT CONVERT(varchar, getdate(), 120 ) 2016-07-20 16:09:01 PRINT replace(replace(replac ...
- sql server中的日期详解使用(convert)
转自:http://blog.csdn.net/hehe520347/article/details/48496853 有个字段值例如2012-07-02 00:00:00.000 转化成 2012- ...
- SQL Server 2008对日期时间类型的改进
微软在备受多年的争议后,终于对日期时间数据类型开刀了,在新版的SQL Server 2008中一口气增加了4种新的日期时间数据类型,包括: Date:一个纯的日期数据类型. Time:一个纯的时间数据 ...
随机推荐
- Spring启动时加载数据
程序中也许有会有许多常用的,不会经常更改的数据,我们可以在程序初始化的时候就把他们加载,就不用频繁的加载或者查询. 以下是几个常用的,有COPY收集的,也有自己弄. 1. 实现BeanPostProc ...
- The plot Function in matlab
from http://pundit.pratt.duke.edu/wiki/MATLAB:Plotting The plot Function The plot function is used t ...
- OpenStack official programs
What are programs ? The OpenStack project mission is to produce the ubiquitous Open Source Cloud Com ...
- squid添加用户名密码认证
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html 内部邀请码:C8E245J (不写邀请码,没有现金送) 国 ...
- DataSource , DataSink, DataSourceLoop
Script assertion in login:
- Codeforces Round #114 (Div. 1) B. Wizards and Huge Prize 概率dp
B. Wizards and Huge Prize Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...
- Codeforces Round #332 (Div. 2) C. Day at the Beach 线段树
C. Day at the Beach Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/599/p ...
- POJ 3522 Slim Span 最小差值生成树
Slim Span Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=3522 Description Gi ...
- 如何将松散的dll打包进需要发布的exe
我们需要发布的exe文件很多时候都可能会依赖于一堆松散的dll,如果想在发布的时候只提供exe文件,而不想把一大堆dll一起放在和exe同一个文件夹下,是有方法的,该方法由CLR via C#作者提出 ...
- [AngualrJS] ng-strict-di
In Angular 1.5 introduces "compoment" syntax. But ng-annotate doesn't understand ".co ...