查询之前需要格式化日期,用to_char(日期,格式)函数进行转换
SELECT D.ORDER_NUM ,D.EMP_NAMEFROM DAT_DOCUMENT dWHERE D.FORM_NAME =\'Form_SD01\'AND TO_CHAR(D.CREATE_TIME,\'yyyy-MM-dd\') BETWEEN \'2019-01-01\' AND \'2020-03-17\';
查询两个日期直接间隔天数:
SELECT TO_char(d.CREATE_TIME,\'yyyy-MM-dd\'),TO_char(d.UPDATE_TIME,\'yyyy-MM-dd\'),trunc(d.UPDATE_TIME) - trunc(d.CREATE_TIME) as daysFROM dat_document d
结果如下: