| Rush |
Posted: Feb 21, 2007 12:12:14 AM |
Total Post: 127
Joined: Jan, 2007
|
hello every body
i have a problem in fetching rows between given two dates.plzzzzzz help me...
i am writing my qury like this
select * from emp where hiredate between to_date('20-sep-81','dd-mon-yy')and to_date('31-dec-81','dd-mon-yy');
is this right or wrong plz give me righ code.my id is->gullu02@gmail.com
thanking you
RUPESH |
|
|
Ghulam |
| Posted: Feb 21, 2007 12:41:49 AM | |
|
Total Post: 8
Joined: Feb, 2007
|
To compare two dates, you must be careful to match same datatype. You can convert all left and right sode variable of comparision operator to either char or date formats.
Below is the tested code plz.
select hire_date from employees where to_date(hire_date, 'dd-mon-yy') between to_date('20-sep-97','dd-mon-yy') and to_date('30-sep-97','dd-mon-yy')
/
|
|
|
|
|
Rush |
| Posted: Feb 21, 2007 01:00:18 AM | |
|
Total Post: 127
Joined: Jan, 2007
|
dear Ghulam i am very very thankful to you.thank you!!!!:-) your code is working and have solved my problem.you are the first person who helped me through dbapool.nice to see your reply.
RUPESH
gullu@gamail.com
|
|
|
|
|
Ghulam |
| Posted: Feb 21, 2007 01:06:12 AM | |
|
Total Post: 8
Joined: Feb, 2007
|
One more tip for you.
Normally functions convert datatype internally (automatically) but thats not the recommended method.
Following code will work properly:
select * from dual where '1' = 1;
But it creates problem when comparing dates!!!!
Cheers
|
|
|
|
|
Rush |
| Posted: Feb 21, 2007 04:30:39 AM | |
|
Total Post: 127
Joined: Jan, 2007
|
thank ghulam to give me tips like this.nice to see you friend!!!!
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |