Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between Working days and minutes CR8.5

Status
Not open for further replies.

PauloMongo

Programmer
Jul 16, 2001
80
0
0
GB
Hi,

I have two dates, start date, end date, both are date/time values.

eg.
Start - 02/09/2004 10:59:39
End - 06/09/2004 10:13:07

Working Periods
Work days - Monday to Friday
Work hours - 8am to 6pm.

I need to create a formula that works out the difference in minutes between these two dates that fall into my working days periods.

I am currently using this formula, but it does not take into account my periods.

Local DateVar DateStart:=cdate({V_SERVICE_CALL.EARLY_START});
Local DateVar DateFinish:=cdate({V_SERVICE_CALL.EARLY_FINISH});
Local TimeVar TimeStart := TimeValue({V_SERVICE_CALL.EARLY_START});
Local TimeVar TimeFinish := TimeValue({V_SERVICE_CALL.EARLY_FINISH});
local numbervar Minutes := DateDiff("n", DateTimeValue(DateStart,TimeStart), DateTimeValue(DateFinish,TimeFinish));


ToText(Truncate(Minutes/60)) + " hours(s), " + ToText(Remainder(Minutes,60)) + " minutes(s)"


ANY HELP WOULD BE GREATLY ACCEPTED.

Thanks,

Paul
 
I am currently getting a date difference between two days
where the field name is the same for both dates so I have a it putting the previous date into a field and then I use the that previous date against the current date. Formula below; but I can't get the sum of this calculation. It tells me that a running total cannot be calculated. What can I do to get this total.

WhilePrintingRecords;
if Shared DateTimeVar PrevDate = DateValue ("01/01/1900 12:00:00AM") then -0 else
(DateDiff ("n",Shared DateTimeVar PrevDate,{Incident_Details.Date})/60)

Thanks.

Suzq2
 
You're using subreports? That's the only time that you need shared variables.

Roll your own sum:

You didn't bother to state where the summaries are displayed, so here's an example for you to adapt (did I see this correctly, you placed a negative zero in there?):

Group Header 1
whileprintingrecords;
numbervar MyNum:=0;

Details fromula
whileprintingrecords;
numbervar MyNum;
if not(Shared DateTimeVar PrevDate = DateValue ("01/01/1900 12:00:00AM")) then
MyNum:=MyNum+(DateDiff ("n",Shared DateTimeVar PrevDate,{Incident_Details.Date})/60)

Group Footer (displaying here)
whileprintingrecords;
numbervar MyNum

If this doesn't work, try posting technical information instead of text descriptions:

Crystal version (you did)
Database/connectivity used
Exmaple data
Expected output

Hopefully this will give you enough to figure the rest out.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top