Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: DateDiff Forumla Calculation Error Post Reply Post New Topic
Author Message
JamesS
Newbie
Newbie
Avatar

Joined: 16 Jul 2009
Location: United States
Online Status: Offline
Posts: 16
Quote JamesS Replybullet Topic: DateDiff Forumla Calculation Error
    Posted: 05 Oct 2009 at 12:48pm
Ok I have a formula which on one row is failing. and for the life of me. I can not figure out why. Since it is working in any other situation.



The report simply shows

@LoggedIn - @LoggedOut - @Diff

If you look at the 8/3 one though you notice that it isn't coming out right at all. Should be in the area of 23,000. but it is coming out 141,

The formula for @Diff is simply

(DateDiff ('s',{@LoggedIn},{@LoggedOut}))

any idea how that is coming up with 141 or more importantly how to fix it?


IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 05 Oct 2009 at 2:37pm
thinking about the math, logged in - logged out is diff, so I would expect low numbers, perhaps the others are not getting a @diff.
 
What I would do to debug this is to duplicate the formula and in each formula display a different value, one has @loggedIn, one @loggedOut, and this way you can see if the math is correct.
 
HTH
IP IP Logged
JamesS
Newbie
Newbie
Avatar

Joined: 16 Jul 2009
Location: United States
Online Status: Offline
Posts: 16
Quote JamesS Replybullet Posted: 06 Oct 2009 at 6:29am
Look at the SS, The first date time is @loggedIn, Second is @loggedOut, and the number is @diff And as you can see it does the math on the others but not on the 8/3 line. Now if I pull this report from 5/1/09 to present the @diff date difference calc works perfectly for EVERY entry except for this one entry on 8/3
IP IP Logged
JamesS
Newbie
Newbie
Avatar

Joined: 16 Jul 2009
Location: United States
Online Status: Offline
Posts: 16
Quote JamesS Replybullet Posted: 06 Oct 2009 at 7:06am
Unless your meaning like this


IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 07 Oct 2009 at 6:39am
Quite honestly, I have looked, and I don't understand your math.  logged out is the minutes since midnight, but I don't get numOfMins, or how you are calculating LoggedIn.
 
The numbers displayed in the first post, are just the datediff in seconds from logged out to logged in. 
 
So, for example if I log in at 8 and out at 4, there is a diff of 8 hours or 8*3600 seconds, but if you take 4pm-8am-diff you get (4-8)-(4-8) which is 0, so that is what I was saying about your equation, I would expect a small number.  Yes, I agree that 8/3 if off but I can't follow what you have done.  Yes, it should be consistent. 
 
What I would suggest to track it down it to print each of your variables that you are using for the calculation out on the report.  You will probably see what has gone wrong when you see the intermediate values.
 
HTH
IP IP Logged
JamesS
Newbie
Newbie
Avatar

Joined: 16 Jul 2009
Location: United States
Online Status: Offline
Posts: 16
Quote JamesS Replybullet Posted: 07 Oct 2009 at 7:18am
I can explain the math. We are a call center, when one of our agents logs out. the TAS software saves to the logout db.

The time stamp is when they logged out. and then you use the field "logged in" which is the number of milliseconds they were logged in to figure out their start time.

Also the times tamp that they use is in minutes and it starts on the 30th of whatever year where as crystal starts on the 31st. So that is why logged in is the time stamp divided by 1440 (number of minutes in a day) + 1 day so that it outputs the correct date.

Numofmins is the number of minutes they were logged in. Again that DB field is in mili-seconds. hence dividing by 1000 to get seconds, then 60 for minutes.

There is no logged in field in the db. to figure that out you have to subtract logged in time from the timestamp when they logged in. hence that is why logged in is what it is.

as it turns out. For whatever reason on that date instead of using the last login datetime like it has every other time. It was using the first. so it was doing the calculation right, just used the wrong value. Just made a max field to get the maximum of loggedout and that fixes the problem and prevents it from reoccuring.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 07 Oct 2009 at 4:05pm
OK, I could figure out the logout was in minutes, didn't realize no 'real' login time.
 
Glad you figured it out.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.012 seconds.