troubleshooting Question

Testing if current date is between two dates

Avatar of nkewney
nkewneyFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL Server
3 Comments1 Solution270 ViewsLast Modified:
I have the SQL query below working from the following tables:

- Activities
- People
- UserList

I want to select another field 'status' - in which the following conditions are tested...

- If today's date is between Activities.Activity_Start and Activities.Activity_End, then return 'Current'
- If today's date is before Activity.Activity_Start then return 'Pending'
- If today's date is past Activities.Activity_End then return 'Archive'

This is my current SQL:

SELECT Activities.Activity_ID, Activities.Activity_Name, People.Person_nameFirst, People.Person_nameLast FROM Activities
INNER JOIN UserList ON Activities.Activity_Owner = UserList.User_Username
INNER JOIN People ON UserList.Person_ID = People.Person_ID
WHERE (Activities.Account_ID = @Account_ID)

Any suggestions on how I can fit this in, i'm getting a bit drowned in SQL!

Any help appreciated.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros