Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Query to locate all records in DB for today

Posted on 2007-12-06
3
Medium Priority
?
186 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

597 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