Date Difference

I have an order date. I need to get all admission dates 90 days before and 90 days
after the order date. The order date is in the orders table and the admission date is
in another table. I am using crystal reports. I tried using datediff but something is off.

Thanks
sashmorhallAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
How are you trying to do this?

Are you using a subreport or is te order date a value provided by the user.

mlmcc
0
sashmorhallAuthor Commented:
I was originally using a subreport but I have to create a side by side bar chart that shows the number of admissions before and the number of admission after.
0
mlmccCommented:
IS the date a parameter to the report?

mlmcc
0
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

sashmorhallAuthor Commented:
The order date will be a parameter.
0
mlmccCommented:
SO you need to select 90 days before and 90 days after

{?Orderdate} = {OrderTable.OrderDate}
AND
{AdmissionTable.AdmitDate} >= {?Orderdate} - 90
AND
{AdmissionTable.AdmitDate} <= {?Orderdate} + 90

mlmcc
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LinInDenverCommented:
Datediff returns the number of days between two dates. You can probably still use it in the report selection filter.

create formula @DateCount
DateDiff ("d", {AdmissionTable.AdmitDate}, {OrderTable.OrderDate})

in the record selection, add a line for
AND {@DateCount} IN -90 TO 90
0
sashmorhallAuthor Commented:
I used datediff("d",order date,admission date) in 1 to 90 and
("d", admission date, order date) in 1 to 90 and it worked fine. I think my original problem was the linking. Thank you very much for you help.


0
mlmccCommented:
If you used what you claim, it can't work since one of the differences has to be negative.
    datediff("d",order date,admission date) in 1 to 90 and ("d", admission date, order date) in 1 to 90

You could use

ABS(datediff("d",order date,admission date)) in 1 to 90

mlmcc

0
mlmccCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.