SQL Server数据库中Date/Time 时间格式的转换[转]
格式转换sql函数convert(nvarchar(12),@date,111):
第一个参数代表要截取的长度,第二个参数代表数据库的字段,最后一个参数代表要截取的日期时间格式,如下表所示:
DATE 日期格式 | ||
格式 # | 查询 (current date: 12/30/2006) | 示例 |
1 | select convert(varchar, getdate(), 1) | 12/30/06 |
2 | select convert(varchar, getdate(), 2) | 06.12.30 |
3 | select convert(varchar, getdate(), 3) | 30/12/06 |
4 | select convert(varchar, getdate(), 4) | 30.12.06 |
5 | select convert(varchar, getdate(), 5) | 30-12-06 |
6 | select convert(varchar, getdate(), 6) | 30 Dec 06 |
7 | select convert(varchar, getdate(), 7) | Dec 30, 06 |
10 | select convert(varchar, getdate(), 10) | 12-30-06 |
11 | select convert(varchar, getdate(), 11) | 06/12/30 |
101 | select convert(varchar, getdate(), 101) | 12/30/2006 |
102 | select convert(varchar, getdate(), 102) | 2006.12.30 |
103 | select convert(varchar, getdate(), 103) | 30/12/2006 |
104 | select convert(varchar, getdate(), 104) | 30.12.2006 |
105 | select convert(varchar, getdate(), 105) | 30-12-2006 |
106 | select convert(varchar, getdate(), 106) | 30 Dec 2006 |
107 | select convert(varchar, getdate(), 107) | Dec 30, 2006 |
110 | select convert(varchar, getdate(), 110) | 12-30-2006 |
111 | select convert(varchar, getdate(), 111) | 2006/12/30 |
TIME 时间格式 | ||
8 or 108 | select convert(varchar, getdate(), 8) | 00:38:54 |
9 or 109 | select convert(varchar, getdate(), 9) | Dec 30 2006 12:38:54:840AM |
14 or 114 | select convert(varchar, getdate(), 14) | 00:38:54:840 |
转载于:https://www.cnblogs.com/tannaiyin/archive/2009/05/07/1451199.html
SQL Server数据库中Date/Time 时间格式的转换[转]相关推荐
- SQL Server数据库中批量导入数据的四种方法总结
在软件项目实施的时候,数据导入一直是项目人员比较头疼的问题.其实,在SQL Server中集成了很多成批导入数据的方法.有些项目实施顾问头疼的问题,在我们数据库管理员眼中,是小菜一碟.现在的重点就是, ...
- 通过VB向SQL Server数据库中录入数据
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 一.数据录入 通过VB向SQL Se ...
- SQL Server数据库中批量导入数据
在软件项目实施的时候,数据导入一直是项目人员比较头疼的问题.其实,在SQL Server中集成了很多成批导入数据的方法.有些项目实施顾问头疼的问题,在我们数据库管理员眼中,是小菜一碟.现在的重点就是, ...
- 在ASP.NET中将图片存储到Sql Server数据库中
在ASP.NET中将图片存储到Sql Server数据库中 http://hi.baidu.com/rayshow/blog/item/360e8ff9662c8b5a252df268.html 索引 ...
- 清空SQL Server数据库中所有表数据的方法(转)
清空SQL Server数据库中所有表数据的方法 其实删除数据库中数据的方法并不复杂,为什么我还要多此一举呢,一是我这里介绍的是删除数据库的所有数据,因为数据之间可能形成相互约束关系,删除操作可能陷入 ...
- 浅析SQL Server数据库中的伪列以及伪列的含义
浅析SQL Server数据库中的伪列以及伪列的含义 原文:浅析SQL Server数据库中的伪列以及伪列的含义 本文出处:http://www.cnblogs.com/wy123/p/6833116 ...
- 如何在SQL Server数据库中加密数据
如何在SQL Server数据库中加密数据 为了防止某些别有用心的人从外部访问数据库,盗取数据库中的用户姓名.密码.信用卡号等其他重要信息,在我们创建数据库驱动的解决方案时,我们首先需要考虑的的第一条 ...
- SQL Server 数据库中的几个常见的临界值
本文出处:http://www.cnblogs.com/wy123/p/6709520.html 1,SQL语句或者存储过程的最大长度(SQL字符串容量)是多少? 经常有人问,我的SQL语句是拼凑出来 ...
- 如何对两个大型SQL Server数据库中的数据进行快速估计比较,以查看它们是否相等
Bringing impactful analysis into a data always comes with challenges. In many cases, we rely on auto ...
最新文章
- Servlet中的配置 web.xml
- InnoDB和MyISAM区别
- 微软发布WP SDK8.0 新增语音、应用内支付等原生API
- 刚开始学Web前端,用什么软件好?
- 电商总结(七)缓存系统
- oracle 邮件过程,oracle 发邮件 存储过程
- html 将盒子固定浏览器,浏览器默认css样式表 css之左盒子固定,右盒子自适应的一种实现方式...
- Linux下运行黑客帝国屏保
- 调戏微软文言文AI翻译:“永不舍汝”、“其母之”是什么鬼???
- 铅蓄电池首批规范企业名单出炉 多家上市公司入围
- oracle spatial特点,Oraclespatial结构取讲解
- 关于OpenCV中cv2.imwrite保存的图片是全黑色的解决方案
- 为什么 K8s 在阿里能成功?
- 在quartus中使用FFT IP核最全教程(从入门到放弃)
- macOS 开发 - AppleScript 简介
- 利用Vultr主机安转宝塔Web面板搭建wordpress博客建站教程
- ubuntukylin-16.04安装
- idea创建maven web项目,pom.xml文件一直显示红色
- 拼多多 2020校园招聘 二维表第k大数(二分)
- PPP学习---天线相位中心改正文件格式学习