SQL Query to locate all records in DB for today
Posted on 2007-12-06
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!