Solved

Returning records created within the last 24 hours

Posted on 2006-06-14
6
305 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 500 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
Independent Software Vendors: 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!

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

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…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 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