Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

[SQL Question] Best way to find all rows using time/date stamps

508560Sep 5 2006 — edited Sep 5 2006
What is the best way to compare two date fields?

I found this thread

944616

But I would have to use some of Oracle's functions to get the results that I need.

I currently have SQL that finds all rows between two dates from the same column (started_time):
select *
	from profiles
		where trunc(started_time)
		between to_date('28-08-2006','DD-MM-YYYY')
		and to_date('29-08-2006','DD-MM-YYYY');
But, I also have a field called completed_time and would like to write SQL that would find all rows between started_time and completed_time.

Here is what I've tried to write:
select *
	from profiles
		where trunc(started_time)
		between to_date('28-08-2006','DD-MM-YYYY')
		and trunc(completed_timing)
                and to_date('29-08-2006','DD-MM-YYYY');
What would be the best way to do this?

thanks

Message was edited by:
cmmiller
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 3 2006
Added on Sep 5 2006
3 comments
210 views