Solved

SQL Query to locate all records in DB for today

Posted on 2007-12-06
3
178 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
3 Comments
 
LVL 25

Accepted Solution

by:
imitchie earned 500 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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Pivot Rows To Columns 10 51
Gettg error - Please help Msg 252, Level 16, State 1, Line 1 3 28
Select only the top record in a left join 13 34
Sql server insert 13 26
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…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

816 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

8 Experts available now in Live!

Get 1:1 Help Now