Solved

Returning records created within the last 24 hours

Posted on 2006-06-14
6
309 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
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!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
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…

623 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