select date [message #202919] |
Mon, 13 November 2006 05:08 |
oracle_coorgi
Messages: 188 Registered: September 2006 Location: INDIA-karnataka
|
Senior Member |
|
|
hi
iam unable to select only record for 07Nov06
if i use between i get records eg:07 november ,2006-0941
Select
TO_CHAR(session_START_time,'dd month,yyyy-hh24mi') LOG_IN_TIME,
TO_CHAR(session_END_time,'dd month,yyyy-hh24mi') LOG_OUT_TIME
from SESSION_LOG
where SESSION_LOG.SESSION_START_TIME
between '06Nov06' AND '07Nov06';
thanxs
|
|
|
Re: select date [message #202937 is a reply to message #202919] |
Mon, 13 November 2006 06:43 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
USE DATES NOT STRINGS!!!!
and,
USE FOUR DIGIT YEARS!!!!
Try this
where trunc(SESSION_LOG.SESSION_START_TIME)
= to_date('07Nov2006'','ddMonyyyy');
|
|
|
Re: select date [message #202946 is a reply to message #202937] |
Mon, 13 November 2006 07:07 |
oracle_coorgi
Messages: 188 Registered: September 2006 Location: INDIA-karnataka
|
Senior Member |
|
|
IT GIVES ERROR
in java we r using this string
BETWEEN TO_DATE('" + fromDate + "', 'ddMonyyyy') AND TO_DATE('" + toDate + "', 'ddMonyyyy')
if any one want the data for the same day eg:07-NOV-2006 then
pls do the needful
|
|
|
|
|
Re: select date [message #202978 is a reply to message #202946] |
Mon, 13 November 2006 08:09 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
oracle_coorgi wrote on Mon, 13 November 2006 08:07 |
if any one want the data for the same day eg:07-NOV-2006 then
pls do the needful
|
I do not understand this statement.
|
|
|
|
Re: select date [message #203009 is a reply to message #202937] |
Mon, 13 November 2006 09:24 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Ooops. Typo. One quote too many.
Should be where trunc(SESSION_LOG.SESSION_START_TIME)
= to_date('07Nov2006','ddMonyyyy');
|
|
|
Re: select date [message #203016 is a reply to message #203009] |
Mon, 13 November 2006 10:03 |
Bill B
Messages: 1971 Registered: December 2004
|
Senior Member |
|
|
JRowbottom wrote on Mon, 13 November 2006 09:24 | Ooops. Typo. One quote too many.
Should be where trunc(SESSION_LOG.SESSION_START_TIME)
= to_date('07Nov2006','ddMonyyyy');
|
Just in case session_start_time is indexed, you can avoid a full table scan with the following
where SESSION_LOG.SESSION_START_TIME between to_date('07Nov2006','ddMonyyyy') AND to_date('07Nov2006','ddMonyyyy')+ (86366/86400) ...;
[Updated on: Mon, 13 November 2006 10:03] Report message to a moderator
|
|
|
Re: select date [message #203090 is a reply to message #203016] |
Mon, 13 November 2006 19:27 |
oracle_coorgi
Messages: 188 Registered: September 2006 Location: INDIA-karnataka
|
Senior Member |
|
|
In JAVA we r using this string
BETWEEN TO_DATE('" + fromDate + "', 'ddMonyyyy') AND TO_DATE('" + toDate + "', 'ddMonyyyy')
oracle syntax THIS IS CORRECT
select
TO_CHAR(session_START_time,'dd month,yyyy-hh24mi') LOG_IN_TIME,
TO_CHAR(session_END_time,'dd month,yyyy-hh24mi') LOG_OUT_TIME
FROM CATS_USER , SESSION_LOG WHERE
SESSION_LOG.SESSION_START_TIME
BETWEEN '01Nov06' AND '06Nov06';
i get data from '01 november ,2006-1021' to '06 november ,2006-1021'
Iam unable to get WITH THIS QUERY
select
TO_CHAR(session_START_time,'dd month,yyyy-hh24mi') LOG_IN_TIME,
TO_CHAR(session_END_time,'dd month,yyyy-hh24mi') LOG_OUT_TIME
FROM CATS_USER , SESSION_LOG WHERE
SESSION_LOG.SESSION_START_TIME
BETWEEN '07Nov06' AND '07Nov06';
fromdate '07 november ,2006-1021' todate '07 november ,2006-1021' that is same date
iwant to select fromdate and todate with same date eg
fromdate='07nov2006' and todate='07nov2006'
thanxs
|
|
|
Re: select date [message #203150 is a reply to message #203090] |
Tue, 14 November 2006 02:03 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
The problem seems to be that your dates in SESSION_LOG.SESSION_START_TIME have a time component stored with them, that you're not taking account of in your WHERE clause.
(I'm assuming that when you write "07 november ,2006-1021" you mean "10:21AM on 7th Nov, 2006")
The clause BETWEEN '07Nov06' AND '07Nov06' (which REALLY should be BETWEEN to_Date('07Nov06','ddMonYY') AND to_date('07Nov06','ddMonYY') - you do know that '07Nov06' is a string and not a date, don't you?) will only match one date, and that is TO_DATE('07-Nov-2006 00:00:00','dd-Mon-yyyy hh24:mi:ss') ie midnight on the 7th of Nov
If you want to fetch all the columns with a date on the 7th of november you cand do the following (2 of which were suggested in the email just above your last one)
where trunc(SESSION_LOG.SESSION_START_TIME) = to_date('07Nov2006','ddMonyyyy'); where SESSION_LOG.SESSION_START_TIME between to_date('07Nov2006','ddMonyyyy') AND to_date('07Nov2006','ddMonyyyy')+ (86366/86400) where SESSION_LOG.SESSION_START_TIME >= to_date('07Nov2006','ddMonyyyy') and SESSION_LOG.SESSION_START_TIME < to_date('08Nov2006','ddMonyyyy')
|
|
|