Home » RDBMS Server » Server Administration » Need Help with Simple SQL query
Need Help with Simple SQL query [message #374188] Tue, 29 May 2001 22:17 Go to next message
Greg
Messages: 35
Registered: July 2000
Member
We use simple SQL queries to extract data from our Oracle Exchange database.

Theres this table with a 'creation_date' column containing date and time data like 2001-05-25 12:53:21.0

I want to extract some other columns together with this one but only data within a 'creation_date' range.

I tried using this several queries like:

select
order_number, creation_date
from
pom_order_headers
where
creation_date
between
2000-12-28 00:00:00.0
and
2001-05-25 00:00:00.0
------ using this I got a "missing keyword" error message

i also tried:

select
order_number, CREATION_DATE
from
pom_order_headers
where
creation_date
between
"2000-12-28 00:00:00.0"
and
"2001-05-25 00:00:00.0"
---but I got an "invalid column name" button

I also tried using # to enclose the date in time but the oracle sql engine doesnt recognize that character

how should I modify this script?
Re: Need Help with Simple SQL query [message #374195 is a reply to message #374188] Wed, 30 May 2001 02:34 Go to previous messageGo to next message
Sandeep P Dandekar
Messages: 3
Registered: October 2000
Junior Member
Try following script

select
order_number, creation_date
from
pom_order_headers
where
trunc(creation_date)
between
to_date(20001228,'yyyymmdd')
and
to_date(20001225,'yyyymmdd')
Re: Need Help with Simple SQL query [message #374198 is a reply to message #374188] Wed, 30 May 2001 03:53 Go to previous messageGo to next message
Zakk
Messages: 5
Registered: May 2001
Junior Member
if you change the date and time fields into varchar(2) and try with "<" and ">" you might have the solution. i had a similar problem. it worked!!
Re: Need Help with Simple SQL query [message #374220 is a reply to message #374198] Thu, 31 May 2001 01:10 Go to previous messageGo to next message
Greg
Messages: 35
Registered: July 2000
Member
Oh no. I'm not familiar with the use of varchar(2). I'm not really a programmer. I only know how to use basic sql queries.

Can you expound on this matter? thanks.
Re: Need Help with Simple SQL query [message #374221 is a reply to message #374198] Thu, 31 May 2001 01:24 Go to previous messageGo to next message
Zakk
Messages: 5
Registered: May 2001
Junior Member
instead of defining the datatype of the date column as "DATE" define it as varchar2 when you make the table..Same goes for time. Check it out. And then when you enter the query run it as:
Select * from (table_name)
where
date < (your greater date value, for eg:30may2001)
and
date >(your lesser date value, for eg:25may2001);
TRY IT.

I tried it once on a similar problem and it worked!!!
Re: Need Help with Simple SQL query [message #374301 is a reply to message #374198] Tue, 05 June 2001 05:07 Go to previous messageGo to next message
shinuq
Messages: 2
Registered: June 2001
Junior Member
try to use the to_char type into your query u will have thew answer with
u
Re: Need Help with Simple SQL query [message #374302 is a reply to message #374198] Tue, 05 June 2001 05:10 Go to previous message
shinuq
Messages: 2
Registered: June 2001
Junior Member
try to use the to_char type into your query u will have thew answer with
u
Previous Topic: Using parameter variables in a "IN" statement
Next Topic: Retrieving a value in Long Column
Goto Forum:
  


Current Time: Fri Jul 05 16:41:33 CDT 2024