?
Solved

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

Posted on 2007-11-29
4
Medium Priority
?
322 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
[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
  • Learn & ask questions
  • 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

719 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