Link to home
Start Free TrialLog in
Avatar of Jagster
Jagster

asked on

Oracle Minimum date function

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...!!

ASKER CERTIFIED SOLUTION
Avatar of AlbertYou
AlbertYou
Flag of Taiwan, Province of China image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.

Avatar of Bigfam5
Bigfam5

You need to be careful with LEAST  if any of the columns are NULL you will get NULL
Avatar of Guy Hengel [angelIII / a3]
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
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