?
Solved

SQL Query to locate all records in DB for today

Posted on 2007-12-06
3
Medium Priority
?
184 Views
Last Modified: 2010-04-21
I am looking to create a SQL Query for my DotNetNuke site through SQL Report Server for all site log activity for today.  Here's what I've got so far:

SELECT     dnn_Portals.PortalName, dnn_SiteLog.DateTime, dnn_Users.Username, dnn_Users.FirstName, dnn_Users.LastName,
                      dnn_Tabs.TabName AS 'Resource Accessed'
FROM         dnn_Users INNER JOIN
                      dnn_SiteLog ON dnn_Users.UserID = dnn_SiteLog.UserId INNER JOIN
                      dnn_Portals ON dnn_SiteLog.PortalId = dnn_Portals.PortalID INNER JOIN
                      dnn_Tabs ON dnn_Portals.PortalID = dnn_Tabs.PortalID
WHERE     (dnn_Portals.PortalID = '0') AND (dnn_SiteLog.DateTime >= CONVERT(datetime, '12/6/2007 12:00:00 AM', 120)) AND
                      (dnn_SiteLog.DateTime < DATEADD(day, 1, CONVERT(datetime, '12/6/2007 11:59:59 PM', 120)))
GROUP BY dnn_Portals.PortalName, dnn_SiteLog.DateTime, dnn_Users.Username, dnn_Users.FirstName, dnn_Users.LastName, dnn_Tabs.TabName

As you can see, I've hard coded today's date, and this is working.  Now, I need to replace the hard coded date with some sort of today function but not sure what that is.

TIA for any help!
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
3 Comments
 
LVL 25

Accepted Solution

by:
imitchie earned 2000 total points
ID: 20424780
SELECT     dnn_Portals.PortalName, dnn_SiteLog.DateTime, dnn_Users.Username, dnn_Users.FirstName, dnn_Users.LastName,
                      dnn_Tabs.TabName AS 'Resource Accessed'
FROM         dnn_Users INNER JOIN
                      dnn_SiteLog ON dnn_Users.UserID = dnn_SiteLog.UserId INNER JOIN
                      dnn_Portals ON dnn_SiteLog.PortalId = dnn_Portals.PortalID INNER JOIN
                      dnn_Tabs ON dnn_Portals.PortalID = dnn_Tabs.PortalID
WHERE     (dnn_Portals.PortalID = '0') AND (dnn_SiteLog.DateTime >= CONVERT(DATETIME,CONVERT(Varchar,Getdate(),102)) ) AND
                      (dnn_SiteLog.DateTime < CONVERT(DATETIME,CONVERT(Varchar,Getdate()+1,102)) )
GROUP BY dnn_Portals.PortalName, dnn_SiteLog.DateTime, dnn_Users.Username, dnn_Users.FirstName, dnn_Users.LastName, dnn_Tabs.TabName
0
 

Expert Comment

by:xpert31415
ID: 20424817
SELECT Today=GETDATE()

returns

Today
---------------------------
2007-12-06 20:07:19.957

0
 

Author Closing Comment

by:dstjohnjr
ID: 31413305
That did it.  Thanks!
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

777 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