How do I set up a date formula to pull yesterday's date's worth of data automatically?

How do I set up a date formula to pull yesterday's date's worth of data automatically?

I see that they have a CurrentDate but nothing for yesterday's date.  I need to set it up so it runs automatically and this is a formula that I need to put in.

Thanks for any help you can give.

Who is Participating?
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.

Kurt ReinhardtSr. Business Intelligence Consultant/ArchitectCommented:
You can simply use:

(CurrentDate - 1)


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
are you using select expert to filter records? You could use dateadd to get yesterday's date, eg)
         dateadd("day", -1, CurrentDate)

In your select expert, use the above syntax to filter your records.

glabossiAuthor Commented:
Yes - I am using select expert
Do you store time in your datetime field? if you don't, you can simply set the filter like:
{table.datefield} = dateadd("day", -1, CurrentDate)   // or kurt's (CurrentDate -1)

if you datetime field is storing time information, then you could use:
({table.datefield} >= dateadd("day", -1, CurrentDate) AND {table.datefield} < CurrentDate)

You will find it is much easier to enter this right into the Formula Editor for the Record Selection, which is what the Select Expert does for you.

Report menu, Selection Formulas, Record.
You can then enter in your formula in the editor there.
Regardless if your field is a date or a datetime, you can use this:

{} = currentdate - 1

Crystal will translate it into the WHERE clause of your SQL with a time stamp if it is a date time or without a timestamp it is just a date.
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.

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.