Greentr
Greentr

Reputation: 3

Crystal Reports 2011 time -24 hours

I have created a report that pulls all the data from the previous day's production. The problem with that is our operations is two shifts and information from second shift is entered around 230 AM the next morning (ex. production was the 15th, but they didn't enter data until 16th at 230AM).

This is the formula that I used:
date({REJECTS.PROD_DATE})=dateadd('d',-1,currentdate).

I tried this formula with the same results: date({REJECTS.TIME_STAMP})=dateadd('h',-24,currentdatetime).

I have verified that REJECTS.TIME_STAMP is a datetime field.

Any help would be great,

Thanks Trevor

Upvotes: 0

Views: 3227

Answers (2)

craig
craig

Reputation: 26262

Add this to your report's record-selection formula:

// timestamp should be new than 24 hours before the current date/time (calculated dynamically)
{REJECTS.TIME_STAMP} >= DateAdd("h", -24, CurrentDateTime)

// include other restrictions as necessary
AND ...

Upvotes: 1

Siva
Siva

Reputation: 9101

My approach would be:

  1. Create a String parameter and give default values for 24 hours... in the required format (either half hour format or Hour format).

If you require check the link for parameters.

2 use below formula in Record Select Expert

{REJECTS.TIME_STAMP}>=Cdatetime(Cdate(dateadd('d',-1,currentdate)),Ctime({?tme})) and
   {REJECTS.TIME_STAMP}<Cdatetime(CDate(dateadd('d',0,currentdate)),Ctime({?time})) and

Now when you run the report you will be prompted for time.. select the time and you query will be formed as required by you.

Upvotes: 0

Related Questions