我需要将日期更改为 sysdate 并保持时间,因为它来自下面的查询
i need to change date as sysdate and keep time as it is from below query
select count (*)
from LOGIN
where LOGTIMEIN >= to_date('14/07/2020 15:30:00', 'dd/mm/yyyy hh24:mi:ss')
我希望日期部分 (14/07/2020) 为系统日期,时间不应更改。我尝试了 sysdate,但没有用
你可以在今天早上 trunc(sysdate)
得到午夜,然后加上 15 小时 30 分钟,或者作为一天的一小部分:
where LOGTIMEIN >= trunc(sysdate) + (15.5/24)
或间隔:
where LOGTIMEIN >= trunc(sysdate) + interval '15:30' hour to minute
快速演示生成的内容:
alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS';
select trunc(sysdate) + (15.5/24) from dual;
| TRUNC(SYSDATE)+(15.5/24) |
| :----------------------- |
| 2020-07-17 15:30:00 |
select trunc(sysdate) + interval '15:30' hour to minute from dual
| TRUNC(SYSDATE)+INTERVAL'15:30'HOURTOMINUTE |
| :----------------------------------------- |
| 2020-07-17 15:30:00 |
select count (*)
from LOGIN
where LOGTIMEIN >= to_date('14/07/2020 15:30:00', 'dd/mm/yyyy hh24:mi:ss')
我希望日期部分 (14/07/2020) 为系统日期,时间不应更改。我尝试了 sysdate,但没有用
你可以在今天早上 trunc(sysdate)
得到午夜,然后加上 15 小时 30 分钟,或者作为一天的一小部分:
where LOGTIMEIN >= trunc(sysdate) + (15.5/24)
或间隔:
where LOGTIMEIN >= trunc(sysdate) + interval '15:30' hour to minute
快速演示生成的内容:
alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS';
select trunc(sysdate) + (15.5/24) from dual;
| TRUNC(SYSDATE)+(15.5/24) |
| :----------------------- |
| 2020-07-17 15:30:00 |
select trunc(sysdate) + interval '15:30' hour to minute from dual
| TRUNC(SYSDATE)+INTERVAL'15:30'HOURTOMINUTE |
| :----------------------------------------- |
| 2020-07-17 15:30:00 |