Pull records for the previous 24 hrs on demand.

Here is the previous question:

I need to pull medication administration records for the previous 24 hrs.  The Date and Time fields are separate and are in text form as 20110324 and 20:01.  What syntax do I need to put in the record selector so I can pull records from the previous 24 hours on demand?

I received this answer and I thought it was working.

Not IsNull({YourDateField})
AND
Not IsNull({YourTimeField})
AND
(
IsTime({YourTimeField}) AND
DateTime(Date(Val(Left({YourDateField},4)), Val(Mid({YourDateField},5,2)), Val(Right({YourDateField},2)))+1,Time({YourTimeField})) >= CurrentDateTime
)


However, I must have been at the end of the report so it looked like it was grabbing the records for the last 24 hrs.  Acutally it pulled all dates AND the Nulls.

Ideas?
LindaOKSTATEAsked:
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:
That should do it.

The Not IsNull should eliminate the NULL values

mlmcc
0
mlmccCommented:
Can you copy and paste the selection formula?

mlmcc
0
LindaOKSTATEAuthor Commented:
(({TABLE.DRUG} like "HYDROCODO*")
or
(({TABLE.DRUG} like "MORPHINE*")
or
({TABLE.DRUG} like "HYDROMORO*")
or
({TABLE.DRUG} like "FENTANYL*")
or
({TABLE.DRUG} like "NARCAN*"))and
Not IsNull({TABLE.DATE}) and
Not IsNull({TABLE.TIME}) and
IsTime({TABLE.TIME}) and
DateTime(Date(Val(Left({TABLE.DATE},4)), Val(Mid({TABLE.DATE},5,2)), Val(Right({TABLE.DATE},2)))+1,Time({TABLE.TIME})) >= CurrentDateTime)
0
mlmccCommented:
I don't know why it is but sometimes Crystal has trouble with complex formulas involving OR and AND

You might try this as

(
Not IsNull({TABLE.DATE})
and
Not IsNull({TABLE.TIME})
and
IsTime({TABLE.TIME})
and
DateTime(Date(Val(Left({TABLE.DATE},4)), Val(Mid({TABLE.DATE},5,2)), Val(Right({TABLE.DATE},2)))+1,Time({TABLE.TIME})) >= CurrentDateTime
)
AND
(
({TABLE.DRUG} like "HYDROCODO*")
or
({TABLE.DRUG} like "MORPHINE*")
or
({TABLE.DRUG} like "HYDROMORO*")
or
({TABLE.DRUG} like "FENTANYL*")
or
({TABLE.DRUG} like "NARCAN*")
)

In putting that together I noticed you have an extra ( after  the first OR.  Try removing it

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
LindaOKSTATEAuthor Commented:
Both the last two comment were useful, they both worked.
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.