select GETDATE()
--2016-01-08 16:15:05.787
select convert(varchar,getdate(),11)
--16/01/08
select convert(varchar,getdate(),23)
--2016-01-08
select convert(varchar,getdate(),24)
--16:39:10
select convert(varchar,getdate(),102)
--2016.01.08
select convert(varchar,getdate(),104)
--08.01.2016
select convert(varchar,getdate(),111)
--2016/01/08
select convert(varchar,getdate(),112)
--20160108
select convert(varchar,getdate(),114)
--16:19:27:533
select convert(varchar,getdate(),120)
--2016-01-08 16:18:39
select convert(varchar,getdate(),0)
--01  8 2016  4:29PM
select convert(varchar,getdate(),1)
--01/08/16
select convert(varchar,getdate(),2)
--16.01.08
select convert(varchar,getdate(),3)
--08/01/16
select convert(varchar,getdate(),4)
--08.01.16
select convert(varchar,getdate(),5)
--08-01-16
select convert(varchar,getdate(),6)
--08 01 16
select convert(varchar,getdate(),7)
--01 08, 16
select convert(varchar,getdate(),8)
--16:33:17
select convert(varchar,getdate(),9)
--01  8 2016  4:34:51:290PM
select convert(varchar,getdate(),10)
--01-08-16
select convert(varchar,getdate(),12)
--160108
select convert(varchar,getdate(),13)
--08 01 2016 16:36:08:463
select convert(varchar,getdate(),14)
--16:36:17:170
select convert(varchar,getdate(),20)
--2016-01-08 16:38:36
select convert(varchar,getdate(),21)
--2016-01-08 16:38:44.963
select convert(varchar,getdate(),22)
--01/08/16  4:39:02 PM
select convert(varchar,getdate(),100)
--01  8 2016  4:44PM
select convert(varchar,getdate(),101)
--01/08/2016
select convert(varchar,getdate(),103)
--08/01/2016
select convert(varchar,getdate(),105)
--08-01-2016
select convert(varchar,getdate(),106)
--08 01 2016
select convert(varchar,getdate(),107)
--01 08, 2016
select convert(varchar,getdate(),108)
--16:47:16
select convert(varchar,getdate(),109)
--01  8 2016  4:47:24:130PM
select convert(varchar,getdate(),110)
--01-08-2016
select convert(varchar,getdate(),113)
--08 01 2016 16:41:46:303
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
--20160108165418

--获取本周
select * from NCIC2009_InterfaceLog where datediff(week,FDATE,getdate())=0

--获取本月
select * from NCIC2009_InterfaceLog where datediff(month,FDATE,getdate())=0
--本季度
select * from NCIC2009_InterfaceLog where datediff(qq,FDATE,getdate())=0
--1-6 /7-12  前半年/后半年
select * from NCIC2009_InterfaceLog where datepart(mm,FDATE)/7 = datepart(mm,getdate())/7
--加两天
select dateadd(day,2,getdate())
--获取两个日期的时间差几天
select datediff(day,'2016-08-01','2016-09-01')
--日期的月份
select DATEPART(month, getdate())
--获取当前日期的星期
select datename(weekday, getdate())
select datename(dw,getdate())
--当前年的第多少周
select datename(week,getdate())
select datename(weekday,getdate())
--获取当前日期的最大天数
SELECT DAY(DATEADD(dd, -1, DATEADD(mm, 1, DATEADD(dd, 1-DAY(getdate()),getdate())))) AS 'Day Number'

sql server 关于日期格式转换查询备注的更多相关文章

  1. sql server 数据库 日期格式转换

    日期时间转字符串:Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM Select CONVERT(varchar(100), ...

  2. Sql Server 常用日期格式

    SQL Server中文版的默认的日期字段datetime格式是yyyy-mm-dd Thh:mm:ss.mmm 例如: select getdate() 2004-09-12 11:06:08.17 ...

  3. Sql Server中Float格式转换字符串varchar方法(转)

    1.[Sql Server](70)  SELECT CONVERT(varchar(100), CAST(@testFloat AS decimal(38,2)))SELECT STR(@testF ...

  4. sql server根据日期或者月份查询聚合数据

    /*****************************根据时间查询每天的数据***************************************/ @tm_start:开始时间 @tm ...

  5. 在SQL Server中 获取日期、日期格式转换

    --常用日期转换参数: PRINT CONVERT(varchar, getdate(), 120 ) 2016-07-20 16:09:01 PRINT replace(replace(replac ...

  6. Sql Server中日期时间格式化为字符串输出

    在SQL Server数据库中,SQL Server日期时间格式转换字符串可以改变SQL Server日期和时间的格式,是每个SQL数据库用户都应该掌握的.本文我们主要就介绍一下SQL Server日 ...

  7. Oracle日期格式转换,tochar(),todate()

    Oracle日期格式转换 本文主要介绍Oracle中的日期转换. 1. 日期转化为字符串 (以2016年10月20日为例) select to_char(sysdate,'yyyy-mm-dd hh2 ...

  8. SQL Server的日期和时间类型

    Sql Server使用 Date 表示日期,time表示时间,使用datetime和datetime2表示日期和时间. 1,秒的精度是指使用多少位小数表示秒 DateTime数据类型秒的精度是3,D ...

  9. SQL SERVER导出特殊格式的平面文件

    有时候我们需要将SQL SERVER的数据一次性导入到ORACLE中,对于数据量大的表.我一般习惯先从SQL SERVER导出特殊格式的平面文件(CSV或TXT),然后用SQL*Loader装载数据到 ...

随机推荐

  1. DOS:第一天

    cd,有时也写作chdir(change directory,改变目录),是在Unix.Windows和DOS操作系统下用于改变工作目录的命令行命令.在Unix的外壳脚本与Windows或DOS的批处 ...

  2. .net core 2.0 报错:error NU1102: Unable to find package 。。。

    这种是nuget无法还原的问题.解决问题的方法: 在项目文件所在的目录下创建文件:NuGet.Config 里面内容: "?> <configuration> <pa ...

  3. Pytorch划分数据集的方法

    之前用过sklearn提供的划分数据集的函数,觉得超级方便.但是在使用TensorFlow和Pytorch的时候一直找不到类似的功能,之前搜索的关键字都是"pytorch split dat ...

  4. L2-013 红色警报 (25 分) (并查集)

    链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805063963230208 题目: 战争中保持各个城市间的连通性非 ...

  5. HtmlWebpackPlugin用的html的ejs模板文件中如何使用条件判断

    折腾: [已解决]给react-hot-boilerplate中的index.html换成用HtmlWebpackPlugin自动生成html 期间,已经有了思路了,但是不知道如何在ejs的html中 ...

  6. 【linux终端操作】

    1. ctr + alt + t 打开新的终端窗口2. ctr + shift + + 终端窗口字体放大3. ctr + - 终端窗口字体缩小4. ls : 查看目录下的文件信息5. pwd: 查看目 ...

  7. Python——类的封装

    class Gun: def __init__(self, model): # 1. 枪的型号 self.model = model # 2. 子弹的数量 self.bullet_count = 0 ...

  8. 7个提升Python程序性能的好习惯

    原文作者:爱coding,会编程的核电工程师. 个人博客地址:zhihu.com/people/zhong-yun-75-63 掌握一些技巧,可尽量提高Python程序性能,也可以避免不必要的资源浪费 ...

  9. JQuery插件:ScrollTo平滑滚动到页面指定位置

    1.准备jQuery库和scrollTo.js插件. <script type="text/javascript" src="js/jquery.js"& ...

  10. Hanlp学习笔记

    一.首先要引入mawen依赖包: <dependency> <groupId>com.hankcs</groupId> <artifactId>hanl ...