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?
 
mlmccConnect With a Mentor Commented:
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
 
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
mlmccCommented:
IS the date a parameter to the report?

mlmcc
0
 
sashmorhallAuthor Commented:
The order date will be a parameter.
0
 
LinInDenverConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.