Solved

# Tracking Logins In CR 8

Posted on 2001-07-06
Medium Priority
267 Views
I have a table that tracks the logins of users to a website.  They login and the table captures there:
[UserID], [Logindate] (Userid is numeric & the Logindate field has both date and time in it).

For a project I need to count how many times a person logged in for a date range, Usually a monthly range, however there is a catch, if the person logs in again and its less than 60 minutes since the last time they logged in, it should only count as 1 login.

I figure I could group by [Userid] and sort the [Logindate] field in Ascending order and create a Formula field that has a "If Then Else" that looks at the current [Logindate]field in the record and compares it to the [Logindate] field in the previous record and if its less than 60 minutes make the Formula field = 0 and if not it = 1, then do a Sum on this field and I should have my problem solved!  However how do I compare against a previous record? Is there a function for this?

P.S. I am using Crystal reports 8 But I also have access to CR 8.5 if needed!
0
Question by:ewalsh
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 7
• 5

LVL 12

Expert Comment

ID: 6260170
EWalsh

Use the PreviousValue({fieldname}) function.  Example to follow in a second.
0

LVL 12

Expert Comment

ID: 6260209
Sorry, gave you wrong syntax

Try something like this

1
else
1
else
if datediff("n", OldDate, CurDate) > 60 then
1
else
0
0

Author Comment

ID: 6267150
Ok, It looks like this works, But know there is a new problem, I cant SUM up on this formula field!
It doesnt list it as a filed in the "Insert Summary"
Or if I try to make a Running Total Field!
I made another formula field that simply showed 1 if it = a specific company name else 0.  And that Formula field WOULD allow me to create a summary or a running total field.
But then I CUt/Copied the original into this test field and then I couldn't use it again!  VERY ODD!!!
I tell you as powerful as CR is I sometimes hate it,  MS Access is so much easier when it comes to this stuff!

P.S.  I tried this on 2 diff machines one running CR 8  the other running CR 8.5
0

Author Comment

ID: 6267156
It seems that if I omit any refrence to Previous()  it will allow to SUM up, But enter a Previous() Function and NO DICE!!!
0

Author Comment

ID: 6267175
I am using Crystal Syntex
0

LVL 12

Expert Comment

ID: 6267177
ewalsh

This would be fairly trivial if you could use VB as a front end to the Crystal Report.  Is that a possibility?
0

Author Comment

ID: 6267553
I'm afraid not.  However, in VBA is there a Previous() Function equivalnt?  If so I'd do it in MS Access.
0

LVL 12

Expert Comment

ID: 6267685
You don't need a previous function.  Build a temp table in Access by using a recordset object to step through your logins table in loginid/date order.  As you step through the original table, compare the login/date time to the previous one that you'll keep in a variable.  A psuedo process to do this...

Open recordset for original file
Open empty recordset for temp file
while not at end of recordset
temprecordset.update
end if
originalrecordset.movenext
loop

This should give you a table in your temp table that contains only one record for any given user within any 60 minute period.  Base your report off the temp table.

Sorry about the sloppy code - I don't have Access at home - but this will get you going.
0

Author Comment

ID: 6277893
Well looks like this is a problem within CR (all version up to 8.5)  Wrote to CR's tech support and this was there reply.
------------------------------

Whileprintingrecords;
Numbervar Counter;
not onfirstrecord;
if datediff ("n", previous
Counter := Counter + 1

This will give you a count for you. However this is not the only formula you will need.
You will need a reset formula for the variable "Counter" in the Group Header that you would like it to reset in. One more to display it. This is referred to as a Manual Running Total and this will be your only option
due to the point of evaluation when using the previous function.

For further information on Manual Running Totals, you can search:
http://support.crystaldecisions.com   for Everything You Need to know
search: scr_running_total.zip

Kind regards,
Tech 909
0

LVL 12

Expert Comment

ID: 6301030
EWalsh

Been away for awhile.  If you want to close the question without awarding points, leave a message in community support asking them to PAQ this question.

DRRYAN3
0

LVL 12

Expert Comment

ID: 6318142
EWalsh

DRRYAN3
0

LVL 12

Accepted Solution

DRRYAN3 earned 1200 total points
ID: 6376393
Since I answered your original question, and you state "looks like this works, but there is a new problem" I am locking this question as I feel I answered it.  You should have opened a new question.

DRRYAN3
0

LVL 1

Expert Comment

ID: 6402497
Force Accepted by:
Moondancer
Community Support Moderator @ Experts Exchange
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirementsâ€¦
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater â€¦
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on tâ€¦
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper cornâ€¦
###### Suggested Courses
Course of the Month15 days, 5 hours left to enroll