Oracle Minimum date function

Jagster
Jagster used Ask the Experts™
on
Is there any function in Oracle like 'MINDATE' or something which can be used to select the minimum date value from a field.

I have a date field called 'ENTDATE', and it can have 3-4 different date values.
Now, I just want to get the minimum of those 3-4 date values.

Basically, I want to use something like
SELECT MIN(ENTDATE);

But since it is a date field thus I can not use the MIN function.

Urgent help needed...!!

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Hi Jaqster,

Yes,you can use the MIN function to get the minimum value
in a date column.

select min(ENTDATE)
from my_table
where ...


Albert.

Commented:
you can use

select min(enddate) from <table>

it will fetch minium enddate in the table.

if you have list of date value. then u can use

select least(date1,date2,date3) from dual, it will gives u the minium of data1, date2, date3.

Commented:
You need to be careful with LEAST  if any of the columns are NULL you will get NULL
Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009

Commented:
If your date fields in in fact a varchar field with a string representing a data, MIN will not work as expected.
You need to convert the varchar value to a date value (using to_date() function. If your field  IS of type date, MIN should work, but if it does not return the value you expect, you should post the data you have (at least some relevant data) the query you use, the result you get and the result you expect.

CHeers

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept AlbertYou's comment as answer
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
jpkemp
EE Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial