Solved

Returning records created within the last 24 hours

Posted on 2006-06-14
6
271 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
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:adilkhan
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now