That didn't seem to work for me, would I perhaps need to use something like
TO_DATE(TO_CHAR(SUBSTR)?
Main Topics
Browse All TopicsHello,
Could you please give me the proper syntax to calculate the # of days betwen dates
both fields are date types and I need a number result.
Date1 - Date2 = #of Days
Also, if the resulting number is (-) how do I assure all #'s will be displayed as (+)
Thanks much as always,
Syhctl
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
no don't need to do that - subtraction of two dates gives a number as the result - from the docs:
"Date Arithmetic
You can add and subtract number constants as well as other dates from dates. Oracle interprets number constants in arithmetic date expressions as numbers of days. For example, SYSDATE + 1 is tomorrow. SYSDATE - 7 is one week ago. SYSDATE + (10/1440) is ten minutes from now. Subtracting the hiredate column of the sample table employees from SYSDATE returns the number of days since each employee was hired. You cannot multiply or divide DATE values."
"Because each date contains a time component, most results of date operations include a fraction. This fraction means a portion of one day. For example, 1.5 days is 36 hours."
What is the result that you are getting?
The statement doesn't run, I get this is the error message I get:
SQL error. Stmt #: 5653 Error Position: 1353 Return: 1722 - ORA-01722: invalid number
A SQL error occurred. Please consult your system log for details.
Error in running query because of SQL Error, Code=1722, Message=ORA-01722: invalid number (50,380)
if your date value is of data type string/char/varchar2 then we should use to_date function as shown below :
if your date1 format is like : '31/01/2007'
if your date2 format is like : '01-dec-2006' ( i am just having it in different
format so you can understand it
better )
then we should use :
select to_date('31/01/2007','dd/m
to_date('01-dec-2006','dd-
from dual;
the return value is positive, if date1 is greater than date2 otherwise negative
value will be returned.
if you always want a positive value, then use ABS
select ABS(
to_date('31/01/2007','dd/m
to_date('01-dec-2006','dd-
from dual;
if your format includes time (hrs,mins,sec) as well and if you do not need to take time into account for the result, then we should use trunc(..) as shown below
select trunc(to_date('31/01/2007'
trunc(to_date('01-dec-2006
from dual;
Thanks
Business Accounts
Answer for Membership
by: ishandoPosted on 2007-11-11 at 15:35:18ID: 20261218
abs(date1 - date2)
if you want whole number of days only then
abs(trunc(date1) - trunc(date2))