Solved

Tracking Logins In CR 8

Posted on 2001-07-06
13
258 Views
Last Modified: 2012-05-04
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
Comment
Question by:ewalsh
  • 7
  • 5
13 Comments
 
LVL 12

Expert Comment

by:DRRYAN3
Comment Utility
EWalsh

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

Expert Comment

by:DRRYAN3
Comment Utility
Sorry, gave you wrong syntax

Try something like this

dateTimeVar OldDate := Previous({logins.logindate});
dateTimeVar CurDate := {logins.loginddate};
stringVar OldLogin := Previous({logins.userid});
stringvar CurLogin := {logins.userid};

if OnFirstRecord or PreviousIsNull({logins.userid}) then
1
else
if OldLogin <> CurLogin then
  1
else
if datediff("n", OldDate, CurDate) > 60 then
1
else
0
0
 

Author Comment

by:ewalsh
Comment Utility
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

by:ewalsh
Comment Utility
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

by:ewalsh
Comment Utility
I am using Crystal Syntex
0
 
LVL 12

Expert Comment

by:DRRYAN3
Comment Utility
ewalsh

This would be fairly trivial if you could use VB as a front end to the Crystal Report.  Is that a possibility?
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:ewalsh
Comment Utility
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

by:DRRYAN3
Comment Utility
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...

dim oLogindate as datetime
dim oLoginID as long
Open recordset for original file
Open empty recordset for temp file
oLoginDate = #01/01/1980#
oLoginID = originalrecordset!loginid
while not at end of recordset
  if datediff('n',oLoginDate, recordset!logindate) > 60 OR oLoginID <> originalrecordset!loginid then
  temprecordset.addnew
  temprecordset!loginid = orginalrecordset!loginid
  temprecordset!logindate = originalrecordset!logindate
  temprecordset.update
  end if
  oLoginDate = originalrecordset!logindate
  oLoginID = originalrecordset!loginID
  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

by:ewalsh
Comment Utility
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.
------------------------------

To resolve your issue you should change your IF statement.

Whileprintingrecords;
Numbervar Counter;
not onfirstrecord;
if datediff ("n", previous
({LOGINRECORD.LOGINDATE}),{LOGINRECORD.LOGINDATE}) > 60 then
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
about running Totals. Or http://support.crystaldecisions.com/library/
search: scr_running_total.zip


Kind regards,
Chad
Tech 909
0
 
LVL 12

Expert Comment

by:DRRYAN3
Comment Utility
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

by:DRRYAN3
Comment Utility
EWalsh

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

Accepted Solution

by:
DRRYAN3 earned 300 total points
Comment Utility
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

by:Moondancer
Comment Utility
Force Accepted by:
Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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 …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now