Select last completed hour.

Hi Experts

I need to be able to select only the records from the last completed hour of the current day.  So if it 8:49 am currently and the report runs, it would only select the records from 7 am until 7:59 am.  

I've tried a number of things but I am just not getting it right.  Your help is greatly appreciated as always.

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.

Raghavendra HullurSoftware DeveloperCommented:

Are you trying to filter only for time part or including date part?

Here is what you can try for time for filtering:

Add a filter condition like {database field} >=time(hour({your time field})-1,00,00) and {database field} <= time(hour({your time field})-1, 59,00)?

Replace {Database field} with time field from database and {your time field} with the time extracted for filtering purpose.

Let us know how it goes.
spudmccAuthor Commented:
It gives me an error.  Date-Time field required and highlights the time(hour area.  I've replaced the database field with the date/time field and the (your time field) with the time extract.
Raghavendra HullurSoftware DeveloperCommented:
Ok, so, you are trying to filter out with a date time field.

Here is what you need to change:

{database field} >= datetime(year({datetime field}),month({datetime field}), day({datetime field}), hour({datetime field})-1,00,00) and {database field} <= datetime(year({datetime field}),month({datetime field}), day({datetime field}), hour({datetime field})-1,59,00)

Hope that helps.

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
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

spudmccAuthor Commented:
Thank you so much.  This solves a problem that has been a "thorn in my side" for some time.  

Raghavendra HullurSoftware DeveloperCommented:
Glad I could help :)
Mike McCrackenSenior ConsultantCommented:
Glad that works but you could try

{database field} >=  DateAdd('h', -1, CUrrentDateTime) AND {database field} <= CurrentDateTime
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.