Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 16:19:26
Original
1711 people have browsed it

方法一 代码如下 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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!