Home  >  Article  >  Database  >  sqlserver 获取date函数年月日格式化

sqlserver 获取date函数年月日格式化

WBOY
WBOYOriginal
2016-06-07 16:19:261712browse

方法一 代码如下 SELECT convert(char(6),getdate(),112) 方法二 代码如下 select* from 表名 where Convert(varchar(100),日期字段,23)='2013-12-15' 使用Convert()函数: select convert(char(10),GetDate(),120) as Date * 第3个参数就是用来设置日期类型

   方法一

 代码如下  

SELECT convert(char(6),getdate(),112)

  方法二

 代码如下  


select * from 表名 where Convert(varchar(100),日期字段,23)='2013-12-15'

  使用Convert()函数:

  select convert(char(10),GetDate(),120) as Date

  * 第3个参数就是用来设置日期类型数据的显示样式的,下面介绍几种样式的参数:

  100 mm dd yyyy

  101 mm/dd/yyyy

  102 yyyy.mm.dd

  103 dd/mm/yyyy

  106 dd mm yyyy

  108 hh:mi:ss(时间)

  111 yyyy/mm/dd

  112 yyyymmdd

  120 yyyy-mm-dd

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn