knrt.net
当前位置:首页 >> sql 查询日期时分秒 >>

sql 查询日期时分秒

declare @date varchar(20) set @date = '2013-06-06 13:30:25' +'%' SELECT * FROM TELEPHONE_HISTORY WHERE CONVERT(VARCHAR(20) ,RECVTIME , 120) LIKE @date 其中:CONVERT(VARCHAR(20) ,RECVTIME , 120) 就是将日期 类型转 “YYYY-MM-DD HH:...

select * from table where CDate(Format(年月日,"yyyy-mm-dd")+时分秒)>CDate('2012-01-01 19:00:00') and CDate(Format(年月日,"yyyy-mm-dd")+时分秒)

还要datetime格式的话 select convert(datetime,convert(varchar(10),getdate(),120)) 如果只要年月日,但是是字符格式的话 select convert(varchar(10),getdate(),120)

转换一下即可: sqlserver: select * from tab where convert(varchar(10),datecol,120) between '2013-04-15' and '2013-05-04' oracle select * from tabxxx where to_char(datecol,'yyyy-mm-dd') between '2013-04-15' and '2013-05-04'

获取年 select to_char(sysdate,'yyyy') from dual--2016 select to_char(sysdate,'YYYY') from dual--2016 获取月 select to_char(sysdate,'mm') from dual--10 select to_char(sysdate,'MM') from dual--10 获取日 select to_char(sysdate,'dd...

需要用sqlserver的convert函数来实现。 语句为: select convert(varchar(10),getdate(),120)运行结果: 下列出一些常用的语法: 输出格式:2008-02-27 00:25:13 SELECT CONVERT(char(19), getdate(), 120) 输出格式:2008-02-27 SELECT CONVERT(...

select distinct Convert(varchar(10),orderdate,120) as "672" from d_orderdetail inner join D_Order on D_Order.orderid=d_orderdetail.orderid where (productid=672) and (Convert(varchar(10),orderdate,120) between '2004-07-01' and '...

select convert(varchar,getdate(),23) select convert(varchar,getdate(),8)

--取'2016-10-18'这天的数据 Select * From case_col_rec Where cast(col_time as date)='2016-10-18' 如果你只是要取某天的数据,不建议你转换数据类型後来匹配,因为那样不会走索引 Select * From case_col_rec Where col_time>='2016-10-18' A...

可以将时间字段格式化成字符型. 例如Oracle数据库 select to_char(时间,'YYYY-MM-DD') FROM 表

网站首页 | 网站地图
All rights reserved Powered by www.knrt.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com