Solved

Date query for report to find active / inactive users logging in within last 6 months

Posted on 2007-11-29
4
317 Views
Last Modified: 2010-04-21
I have a DotNet site that I am creating some reports for with SQL Reporting Services 2005 and I need to build a query that will show me the following:

1. Active Users (logging into site within last 6 months)
2. Inactive Users (have not logged into site within last 6 months)

This is from the standard aspnet_Users log table.  The date field to query is called "LastActivityDate".

TIA for any expert knowledge!
0
Comment
Question by:dstjohnjr
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:imitchie
ID: 20378759
Active:
select * from aspnet_Users
where DateAdd(m, -6, getdate() <= LastActivityDate

InActive:
select * from aspnet_Users
where DateAdd(m, -6, getdate() > LastActivityDate
0
 

Author Comment

by:dstjohnjr
ID: 20378861
Hmmm.... That doesn't appear to be it.

select * from aspnet_Users
where DateAdd(m, -6, getdate() <= LastActivityDate)

First off, I needed to add a closing paren.

Next, I'm getting this error:

Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '<'.

Is that the right operator for Less than or equal to?

Thanks for your help!
0
 
LVL 25

Accepted Solution

by:
imitchie earned 500 total points
ID: 20379069
crikey! my mind is getting blinded by the brackets... sorry

Active:
select * from aspnet_Users
where DateAdd(m, -6, getdate()) <= LastActivityDate

InActive:
select * from aspnet_Users
where DateAdd(m, -6, getdate()) > LastActivityDate
0
 

Author Closing Comment

by:dstjohnjr
ID: 31411834
Sorry this is so late.  Thanks for the excellent expert help!
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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

820 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