sql查询日期型内容+oracle

查询当日数据

select *
from Ct_q_Data
where trunc(Sampdate) = trunc(sysdate)

查询当日数据的另一种写法

select *
from tabname
where dtcol >= trunc(sysdate) and dtcol < trunc(sysdate) + 1

查询某日数据

select *
from Ct_q_Data
where Sampdate >=
trunc(to_date('2021-04-08 00:00:00', 'yyyy-MM-dd HH24:mi:ss'))
and Sampdate <
trunc(to_date('2021-04-08 00:00:00', 'yyyy-MM-dd HH24:mi:ss')) + 1

查询系统时间

select sysdate from dual

日期转字符串:

select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual;

字符串转日期

select to_date('2005-01-01 13:14:20','yyyy-MM-dd HH24:mi:ss') from dual;
posted @ 2021-04-23 10:11  郗王宸  阅读(179)  评论(0编辑  收藏  举报