Home » RDBMS Server » Server Administration » Date function
Date function [message #373402] Sat, 14 April 2001 02:25 Go to next message
Kumar
Messages: 115
Registered: December 1998
Senior Member
I uesd trunc in date function.But still it is not working.

I am telling my problem one more time.

I want to select the employee list who joined between the 2 dates.

suppose i am giving 11 to 14.I am getting only 12,13,14th data.I am
not getting 11th data.This is my problem.

I used the query is

Select emp from emptable where
date>=trunc(to_date('"+from+"','dd-mm-yyyy')) and
date<=trunc(to_date('"+to+"','dd-mm-yyyy'))" ;

please find the error in the above query and reply me asap.

thanks in advance
regards
kumar

ORAFAQ.sql.Message.Board@masterpromotion.com wrote:

Dear Oracle FAQ User,

We just wanted to let you know that Madhav replied
to your message on the Oracle FAQ sql message forum.
The complete message is available at:

http://www.orafaq.com/msgboard/sql/messages/4830.htm

Message Text: Re: Query

Hi,
use trunc on from & to dates....
above condition is comparing timestamps too...
when u are using date comparision better using
trunc...
select ...
from....
where trunc(col_date) between
trunc(fr_date) and trunc(to_date)...
HTH
Madhav
---

This e-mail message was automatically generated by
the Oracle FAQ Message Board at http://www.orafaq.com/.
Please do NOT reply to this message, rather go to the
FAQ and reply on the relevant message forum.

Thank you for your support.

Sincerely,
The Oracle FAQ Team
Re: Date function [message #373404 is a reply to message #373402] Sat, 14 April 2001 11:33 Go to previous messageGo to next message
Madhav Kasojjala
Messages: 42
Registered: November 2000
Member
Hi,
You still haven't used trunc function either side.
This should work
Select emp from emptable where
trunc(date)>=trunc(to_date('"+from+"','dd-mm-yyyy')) and
trunc(date)<=trunc(to_date('"+to+"','dd-mm-yyyy'))" ;
Re: Date function [message #373421 is a reply to message #373402] Mon, 16 April 2001 11:12 Go to previous message
Hari
Messages: 59
Registered: August 2000
Member
Start_Date : 01/11/01
end_date : 01/14/01

Select emp_name,empsalary from emp
where hire_date between trunc(start_date) and trunc(end_date) + 0.99999.

This will select all the employee records from
01/11/01 00:00:00 to
01/14/01 23:59:59

Hope this helps
Previous Topic: export
Next Topic: Re: Latest updated rows
Goto Forum:
  


Current Time: Tue Jul 02 13:27:00 CDT 2024