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. zip4j压缩

    使用的jar包:zip4j_1.3.2.jar 基本功能: 针对ZIP压缩文件创建.添加.分卷.更新和移除文件 (读写有密码保护的Zip文件) (支持AES 128/256算法加密) (支持标准Zip ...

  2. Win10蓝屏的一些解决办法

    请仔细回想这个错误是什么时候出现的: 第一次发生时你对系统做了哪些操作: 发生时正在进行什么操作: 从这些信息中找出可能的原因: 从而选择相应解决方案并尝试排除. 0x0000000A:IRQL_NO ...

  3. 只有try和finally,没有catch

    因为没有catch捕获异常,所以异常发生时,会将异常抛出,导致程序中止:在抛出之前会执行finally中的代码. 用于无法捕获处理异常,需要在程序结束之前进行善后处理的场景

  4. tensorflow 莫烦教程

    1,感谢莫烦 2,第一个实例:用tf拟合线性函数 import tensorflow as tf import numpy as np # create data x_data = np.random ...

  5. redhat7初始化yum源

    1.卸载原有的yum [app@localhost ~]$ su - root Password: Last :: CST on pts/ [root@localhost ~]# cd /etc/yu ...

  6. 解决sqlite 删除记录后数据库文件大小不变

    最的做的项目中要有到sqlite数据存储,写了测试程序进行测试,存入300万条记录,占用flash大小为 86.1M,当把表中的记录全部删除后发后数据库文件大小依然是 86.1M: 原因是:sqlit ...

  7. js数据结构与算法——字典与散列表

    <script> //创建字典 function Dictionary(){ var items = {}; this.set = function(key,value){ //向字典添加 ...

  8. C# emgu 多模板匹配

    public MatchInfo GetMatchPos(string Src, string Template) { MatchInfo myMatchInfo = new MatchInfo(); ...

  9. 让oracle数据库的表的id自动递增

    1.创建递增序列 CREATE SEQUENCE  ID_ADD(序列名称)INCREMENT BY 1START WITH 1MINVALUE 1NOMAXVALUE; 2.创建触发器绑定到表上cr ...

  10. Oracle DBA 必须掌握的 查询脚本:

    Oracle  DBA 必须掌握的 查询脚本: 0:启动与关闭 orcle 数据库的启动与关闭 1:连接数据库 2:数据库开启状态的实现步骤:       2-1:启动数据库           2- ...