sysdate function in oracle - TechRepublic
Question
February 20, 2009 at 06:17 AM
jdobyns

sysdate function in oracle

by jdobyns . Updated 17 years, 4 months ago

I want to be able to run a query everyday beginning at 6am this morning to 6am yesterday morning. The query will always be run after 6am. We are running a 9i Oracle database. I have been unable to get the syntax correct. Here is a description of the table.

Name Null? Type
——————————- ——– —-
TAG_REF_NO NOT NULL NUMBER(5)
IN_OUT NOT NULL VARCHAR2(1)
C_DT NOT NULL DATE
TRANSACTION_NO NOT NULL NUMBER(12)
GROSS_WT NOT NULL NUMBER(11,3)
FRONT_AXLE NOT NULL NUMBER(11,3)
DRIVE_AXLE NOT NULL NUMBER(11,3)
TANDEM_AXLE NOT NULL NUMBER(11,3)

example:

select * from table_name
where c_dt > = sysdate (06:00:00) -1

I know that is not correct but that is what I am trying to accomplish. Thanks in advance!

Update: I have gotten this far but with an inconsistant data type error:

1 select tag_ref_no, in_out, to_char(c_dt,’mm/dd/yyyy hh24:mi’), transaction_no
2 from api_Scale
3 where c_dt between to_char(trunc(sysdate) +6/24, ‘MM/DD/YYYY HH24:MI’)
4* and to_char(trunc(sysdate) +6/24, ‘MM/DD/YYYY HH24:MI’) -1
SQL> /
where c_dt between to_char(trunc(sysdate) +6/24, ‘MM/DD/YYYY HH24:MI’)
*
ERROR at line 3:
ORA-00932: inconsistent datatypes

This discussion is locked

All Comments