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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date diffrence in hours

Status
Not open for further replies.

shanila

IS-IT--Management
Jan 5, 2011
3
GB
I am using crystal report 10 to generate report from a ticketing tool TOUCH PAPER.It is pulling data from a database.In that database ticket_assigened_Date is hard coded like below.

31401986

using the formulae "DateVar Assgn_date := HelpDeskDateFieldToDate ({CALL_HDW.CALLDAT_HDW}); " i converted it in to

02/09/2005

Like this we have assined_time,ticket closed date,ticket closed time also.

For findin SLA i need to find out the differece between ticket assigned date/time and ticket closed date/time.

for this i used the formulae:

DateTimeVar AssgnDateTime := DateTime ({@Actual_Start_Date},{@Actual_Start_time});
DateTimeVar ResDateTime := DateTime ({@Res_date},{@Res_Time});

StringVar TimeSinceBreach := DateTimeDiff(AssgnDateTime,ResDateTime);

NumberVar MinPos := InStr (1,TimeSinceBreach ,"Minute(s)" );

Mid (TimeSinceBreach,1 ,MinPos + 8 )


But above formulae is giving the result as 1day 4 hour 20 minutes...i want the SLA just in hours that means 1 day 4 hour 20 minutes should be 28 hours.

how can i write the formulae for that
 
Change this to use DateDiff

StringVar TimeSinceBreach := DateTimeDiff(AssgnDateTime,ResDateTime);

StringVar TimeSinceBreach := DateDiff("h",AssgnDateTime,ResDateTime);

This will return hours

Ian
 
its throwing the error "A string is required here
 
Sorry datdiff returns a number

Try

NumberVar TimeSinceBreach := DateDiff("h",AssgnDateTime,ResDateTime);

Ian
 
I tried using the below query:

DateTimeVar AssgnDateTime := DateTime ({@Actual_Start_Date},{@Actual_Start_time});
DateTimeVar ClockCloseDateTime := DateTime ({@CLOCK STOP DATE},{@CLOCK STOP TIME});

NumberVar TimeSinceBreach := DateDiff("h",AssgnDateTime,ClockCloseDateTime);

NumberVar MinPos := InStr (1,TimeSinceBreach,"Minute(s)" );

Mid (TimeSinceBreach,1 ,MinPos + 8 )

But it is showing a string is required here in the line
NumberVar MinPos := InStr (1,TimeSinceBreach,"Minute(s)" );
 
Why do you need that any more

remove

NumberVar MinPos := InStr (1,TimeSinceBreach,"Minute(s)" ); Mid (TimeSinceBreach,1 ,MinPos + 8 )

The var TimeSinceBreach now returns hours directly.
 



Brute force:

Since Date/Time values are simply NUMBERS...

Calculate the difference between the two values, which has units of DAYS.

Perform a simple 3rd grade conversion of DAYS to HOURS; 24 hrs per day.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top