Oracle can easily do date arithmetic (subtracting one date value from another) and will give you the result in days by default. If one of the values is already a "date" datatype (like from a "date" column in a table) no conversion is necessary for that value. If either or both values though are character strings, you need to use "to_date" with an appropriate format mask to convert the value(s) to date(s) first. If the character strings have a consistent format, this is quite easy. If the character strings have a variety of formats though, then the task becomes difficult or impossible to automate.
Main Topics
Browse All Topics





by: angelIIIPosted on 2007-07-20 at 11:49:14ID: 19533944
the result is correct, because you said dd-mon-yyyy and you have only 07 as year.
/YYYY') - to_date('13-JUN-07', 'dd-mon-yy') from dual;
this will give the result you expect:
select to_date('6/24/2007','MM/DD