oracle 取当天日期减一天 应该如何写
2022-12-02 · 百度认证:北京惠企网络技术有限公司官方账号
1、创建测试表,
create table test_sysdate(v_date date);
2、插入测试数据
insert into test_sysdate values(sysdate);
insert into test_sysdate values(sysdate-1);
insert into test_sysdate values(sysdate-1.1);
insert into test_sysdate values(sysdate-1.2);
insert into test_sysdate values(sysdate-2);
insert into test_sysdate values(sysdate-3);
3、查询表中所有记录数,select t.*, rowid from test_sysdate t,
4、编写sql,查询日期为前一天的记录,select t.*, rowid from test_sysdate t where to_char(v_date,'yyyymmdd') = to_char(sysdate-1,'yyyymmdd')
1、创建测试表,
create table test_sysdate(v_date date);
2、插入测试数据
insert into test_sysdate values(sysdate);
insert into test_sysdate values(sysdate-1);
insert into test_sysdate values(sysdate-1.1);
insert into test_sysdate values(sysdate-1.2);
insert into test_sysdate values(sysdate-2);
insert into test_sysdate values(sysdate-3);
3、查询表中所有记录数,select t.*, rowid from test_sysdate t,
4、编写sql,查询日期为前一天的记录,select t.*, rowid from test_sysdate t where to_char(v_date,'yyyymmdd') = to_char(sysdate-1,'yyyymmdd')
select trunc(sysdate)-1 from dual;
这些都是OK的,我亲自试过
select to_char(sysdate-1,'yyyymmdd') from dual;