Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Returning records created within the last 24 hours

Posted on 2006-06-14
6
Medium Priority
?
314 Views
Last Modified: 2008-02-01
I am trying to write this query in ASP for a MSSQL database so that it finds the records with the field 'datetime' in the past 24 hours.  Right now it just return the one with todays date:

strsqlg = "SELECT COUNT(*) AS SaleCount FROM [tblSales] WHERE sellerID="&Session(UserID)&" AND dateTime ="&date()
0
Comment
Question by:JuniorBee
[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
6 Comments
 
LVL 11

Accepted Solution

by:
kelvinwkw earned 2000 total points
ID: 16908375
strsqlg = "SELECT COUNT(*) AS SaleCount FROM [tblSales] WHERE sellerID="&Session(UserID)&" AND dateTime >= '" & now() - 1 & "'"
0
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 16908560
strsqlg = "SELECT COUNT(*) AS SaleCount FROM [tblSales] WHERE sellerID="&Session(UserID)&" AND [dateTime] >= '"& DateAdd('h', -24, Date()) &"'"
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16908743
strsqlg = "SELECT COUNT(*) AS SaleCount FROM [tblSales] WHERE sellerID=" & Session(UserID) & " AND [dateTime] >= GETDATE() - 1"
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16908747
Or strictly speaking:
strsqlg = "SELECT COUNT(*) AS SaleCount FROM [tblSales] WHERE sellerID=" & Session(UserID) & " AND [dateTime] BETWEEN GETDATE() - 1 AND GETDATE()"
0
 

Author Comment

by:JuniorBee
ID: 16908918
Thanks for all your answers.  First one worked so I accepted that one.  =)
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16913541
Not a problem.  Glad you got your problem solved.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

721 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