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!

Formatting datetime stamp

Status
Not open for further replies.

maddyyikes

IS-IT--Management
Jul 19, 2004
32
0
0
US
Hi,
I have used the following code from this site to calculate business hours for my report. I am using Crystal Reports 8.5

local numbervar numDayStartHour:=8; //The hour that work starts in 24 hour time.
local numbervar numDayStartMinute:=0; //The minutes value of the time when work starts

local numbervar numDayEndHour:=17; //The hour that work ends in 24 hour time
local numbervar numDayEndMinute:=0; //The minutes value of the time when work ends

local numbervar numWholeDaysBetween; //The whole days between two datetimes
local timevar tmDayStart:=time(numDayStartHour,numDayStartMinute,0); //Convert the start hour and minutes to a time
local timevar tmDayEnd:=time(numDayEndHour,numDayEndMinute,0); //Convert the end hour and minutes to a time
local numbervar numMinutesInWholeDay; //Minutes in a whole day based on tmDayStart and tmDayEnd
local numbervar numMinutesInStartDay;
local numbervar numMinutesInEndDay;
local numbervar numTotalMinutes;
local numbervar numDivider:=60; //This is here in case we want to switch our formula over to seconds, later.


//whole days between, excluding weekends
// this is a pretty standard method
numWholeDaysBetween:=datediff("d",{probsummarym1.open.time},{probsummarym1.close.time})
-
(DateDiff ("ww", {probsummarym1.open.time}, {probsummarym1.close.time}, crSunday) +
DateDiff ("ww", {probsummarym1.open.time}, {probsummarym1.close.time}, crSaturday));



//Calculate minutes in a whole day
numMinutesInWholeDay:=(tmDayEnd-tmDayStart)/numDivider;

//Calculate minutes in start day
// beginning time to tmDayEnd
numMinutesInStartDay:=
(
(tmDayEnd-maximum(tmDayStart to timevalue({probsummarym1.open.time})))/numDivider //The maximum is used to determine if we're inside the workday
);

//Calculate minutes in end day
// tmDayStart to End Time
numMinutesInEndDay:=
(
((minimum(timevalue({probsummarym1.close.time}) to tmDayEnd))-tmDayStart)/numDivider //The minimum is used to determine if we're inside the workday
);

//Calculate all minutes:
numTotalMinutes:=
numMinutesInEndDay+numMinutesInStartDay //First and Last day minutes
+
(((numWholeDaysBetween)-1)*numMinutesInWholeDay); //Whole days between minutes. The -1 is there because of the first and last day being included above.

//Get the hours from the minutes
numTotalMinutes/60;

The code works fine, however I need to compare it with different Service Level Agreements in place based on different severity levels.
Example:

SLA for severity level 3 ticket = 4 business hours.
SLA for severity level 4 ticket = 8 business hours.
I need to compare the business hours generated by the above code snippet with the SLA requirements and determine the difference between the two so as to show the delay (if any) in not meeting SLA requirements. Moreover, the above code outputs values such as 39.12 (for instance) which needs to be converted to a datetime stamp and compared with the required SLA standards. Also, it is desirable to have the output in the following format:
"Did not meet SLA Requirements. Delayed by xx days,xx hours,xx mins when compared with required SLA Standards"

I would appreciate if you could help me out with the same at your earliest convenience. Thanks in advance!
~Maddy


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top