Time from Date field [message #308923] |
Tue, 25 March 2008 23:36  |
kumarvk
Messages: 214 Registered: July 2004
|
Senior Member |
|
|
Hi,
I have the following sql like this
select rno,rdate from job_table where
RODATE BETWEEN To_date('01-MAR-08 08:30:00','dd-mon-yy hh24:mi:ss') AND
To_date('26-MAR-08 11:00:00','dd-mon-yy hh24:mi:ss')
Actually I want to extract only the reocrds for all the days which has time between 8.30-11.00 only but I am getting all the records having in between these dates. If I give single date then I am able to get between 8.30-11.00 but I want for all the days between 8.30-11.00
Can anyone help me?
|
|
|
|
|
Re: Time from Date field [message #308929 is a reply to message #308923] |
Wed, 26 March 2008 00:11   |
mshrkshl
Messages: 247 Registered: September 2006 Location: New Delhi
|
Senior Member |
|
|
the date and hour condition must be separated in two conditions.
always post what you have done and what is current problem.
regards,
|
|
|
Re: Time from Date field [message #308943 is a reply to message #308929] |
Wed, 26 March 2008 00:51   |
kumarvk
Messages: 214 Registered: July 2004
|
Senior Member |
|
|
Hi,
I did like this also
select rno,rdate from job_table where
RODATE BETWEEN To_date('01-MAR-08 08:30:00','dd-mon-yy hh24:mi:ss') AND
To_date('26-MAR-08 11:00:00','dd-mon-yy hh24:mi:ss')
and rodate between to_date('08:30:00', 'hh24:mi:ss') and
to_date('11:00:00','hh24:mi:ss')
But the output result is wrong.
|
|
|
|
|
Re: Time from Date field [message #308959 is a reply to message #308949] |
Wed, 26 March 2008 01:35   |
kumarvk
Messages: 214 Registered: July 2004
|
Senior Member |
|
|
Hi,
I get the result like this only, if I use my sql.
RO NO RO DATE
RA0101236 01-03-08 8:52
RA0101239 01-03-08 9:20
RA0101241 01-03-08 10:07
RA0101251 01-03-08 10:52
RA0101237 01-03-08 9:14
RA0101238 01-03-08 9:20
RA0101240 01-03-08 9:24
RA0101242 01-03-08 10:09
RA0101243 01-03-08 10:15
RA0101244 01-03-08 10:20
RA0101246 01-03-08 10:27
RA0101247 01-03-08 10:31
RA0101248 01-03-08 10:39
RA0101249 01-03-08 10:42
RA0101250 01-03-08 10:49
RA0101252 01-03-08 10:53
RA0101245 01-03-08 10:21
|
|
|
Re: Time from Date field [message #308965 is a reply to message #308923] |
Wed, 26 March 2008 01:44   |
mintomohan
Messages: 104 Registered: November 2006 Location: India
|
Senior Member |
|
|
hi,
could you please try this one:
SELECT rno, rdate
FROM job_table
WHERE rodate BETWEEN TO_DATE ('01-MAR-08 08:30:00', 'dd-mon-yy hh24:mi:ss')
AND TO_DATE ('26-MAR-08 11:00:00', 'dd-mon-yy hh24:mi:ss')
AND TO_CHAR (SYSDATE, 'DD-MON-YY ') || TO_CHAR (rodate, 'HH24:MI:SS')
BETWEEN TO_CHAR (SYSDATE, 'DD-MON-YY ')
|| TO_CHAR (TO_DATE ('01-MAR-08 08:30:00',
'dd-mon-yy hh24:mi:ss'
),
'HH24:MI:SS'
)
AND TO_CHAR (SYSDATE, 'DD-MON-YY ')
|| TO_CHAR (TO_DATE ('26-MAR-08 11:00:00',
'dd-mon-yy hh24:mi:ss'
),
'HH24:MI:SS'
);
Minto
|
|
|
|
|
Re: Time from Date field [message #308977 is a reply to message #308976] |
Wed, 26 March 2008 02:09   |
mintomohan
Messages: 104 Registered: November 2006 Location: India
|
Senior Member |
|
|
you are right Michel,
i think this this one will serve the purpose:
SELECT rno, rodate
FROM job_table
WHERE rodate BETWEEN TO_DATE ('01-MAR-08 08:30:00', 'dd-mon-yy hh24:mi:ss')
AND TO_DATE ('26-MAR-08 11:00:00', 'dd-mon-yy hh24:mi:ss')
AND TO_CHAR (rodate, 'HH24:MI:SS') BETWEEN '08:30:00' AND '11:00:00';
Minto
|
|
|
|
|
|
|
|
|
|