Solved

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

Posted on 2007-11-29
4
314 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
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 video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

708 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

13 Experts available now in Live!

Get 1:1 Help Now