仅从Oracle SQL中给定的时间戳中提取日期 [英] extract date only from given timestamp in oracle sql
本文介绍了仅从Oracle SQL中给定的时间戳中提取日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下查询:
select cdate from rprt where cdate <= TO_CHAR(sysdate, 'YYYY/MM/DD-HH24-MI-SS-SSSSS') and ryg='R' and cnum='C002';
返回:2013/04/27-10:06:26:794
如表中所存储.
我只想获取日期为:27-04-2013
,并获取resul tdate和sysdate之间的天数.
I want to get the date only as : 27-04-2013
and get the number of days between the resul tdate and sysdate.
推荐答案
使用函数cast()从时间戳转换为日期
Use the function cast() to convert from timestamp to date
select to_char(cast(sysdate as date),'DD-MM-YYYY') from dual;
有关函数转换oracle11g的更多信息,请 http://docs.oracle. com/cd/B28359_01/server.111/b28286/functions016.htm#SQLRF51256
For more info of function cast oracle11g http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions016.htm#SQLRF51256
这篇关于仅从Oracle SQL中给定的时间戳中提取日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文