Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-11-29
4
Medium Priority
?
325 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 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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 extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

972 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