Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Truncating and Calculating date time difference Post Reply Post New Topic
Author Message
Ringo000
Newbie
Newbie


Joined: 12 Jul 2010
Location: New Zealand
Online Status: Offline
Posts: 1
Quote Ringo000 Replybullet Topic: Truncating and Calculating date time difference
     Posted: 12 Jul 2010 at 2:43pm
Hi - We are trying to retreive mins of a call being openned in Crystal
 
See the formula below. It is not working correctly. Does anyone see the problem and the way we can fix it.

Local numbervar SubmitH:=Hour({HPD_Help_Desk.Submit Date});
Local numbervar SubmitM:=Minute({HPD_Help_Desk.Submit Date});
Local datevar SubmitDay:=date({HPD_Help_Desk.Submit Date});
Local DateTimeVar Submit;
Local numbervar ResolveH:=Hour({HPD_Help_Desk.Last Resolved Date});
Local numbervar ResolveM:=Minute({HPD_Help_Desk.Last Resolved Date});
Local datevar ResolveDay:=date({HPD_Help_Desk.Last Resolved Date});
Local DateTimeVar Resolve;
WhileReadingRecords;
If SubmitH < 9 then (SubmitH:=9; SubmitM:=0);
If SubmitH > 17 then (SubmitH:=9; SubmitM:=0; SubmitDay:=date({HPD_Help_Desk.Submit Date}) + 1);
If Dayofweek(SubmitDay)= 1 then (SubmitH:=9; SubmitM:=0; SubmitDay:=date({HPD_Help_Desk.Submit Date}) + 1);
If Dayofweek(SubmitDay)= 7 then (SubmitH:=9; SubmitM:=0; SubmitDay:=date({HPD_Help_Desk.Submit Date}) + 2);
If ResolveH < 9 then (ResolveH:=9; ResolveM:=0);
If ResolveH > 17 then (ResolveH:=9; ResolveM:=0; ResolveDay:=date({HPD_Help_Desk.Last Resolved Date}) + 1);
If Dayofweek(ResolveDay)= 1 then (ResolveH:=9; ResolveM:=0; ResolveDay:=date({HPD_Help_Desk.Last Resolved Date}) + 1);
If Dayofweek(ResolveDay)= 7 then (ResolveH:=9; ResolveM:=0; ResolveDay:=date({HPD_Help_Desk.Last Resolved Date}) + 2);


Submit:=DateTime(year({HPD_Help_Desk.Submit Date}),Month({HPD_Help_Desk.Submit Date}),day(SubmitDay),SubmitH,SubmitM,0);
Resolve:=DateTime(year({HPD_Help_Desk.Last Resolved Date}),Month({HPD_Help_Desk.Last Resolved Date}),day(ResolveDay),ResolveH,ResolveM,0);
DateDiff("n",Submit,Resolve)-(((DateDiff("ww",SubmitDay,ResolveDay,crSaturday)*8*60)+ (datediff("ww",SubmitDay,ResolveDay,crSunday))*8*60)+ (datediff("d",SubmitDay,ResolveDay)*16*60))

we then truncate the mins into hours and mins as so:
local numbervar Hr := Truncate({@mins to Resolve}/60);
local numbervar Mn := Remainder({@mins to Resolve},60);
 
this also does not seem to be producing the desired result.
 
any help would be grateful
Rick
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum