Solved

Tracking Logins In CR 8

Posted on 2001-07-06
13
262 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
ID: 6260170
EWalsh

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

Expert Comment

by:DRRYAN3
ID: 6260209
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
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

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

by:ewalsh
ID: 6267175
I am using Crystal Syntex
0
 
LVL 12

Expert Comment

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

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

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

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
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.
------------------------------

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
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

by:DRRYAN3
ID: 6318142
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
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

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Insert timestamp data field of max summary 8 45
Crystal Reports last day of month 2 61
Exclude some records from totals 10 58
Crystal Reports Version 7 4 33
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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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