Solved

SQL query to pull today's transactions

Posted on 2013-02-07
4
164 Views
Last Modified: 2013-02-07
I have an access database that logs history using the =Now() function into a field called TimeStamp.  I'd like a simple query to pull all records with a certain date, but since each record also has a time attached, all my results return blank.

I'm thinking ...

SELECT * from tblHistory WHERE TimeStamp = "02/07/13"

But the recordset returns empty because the underlying data is ...

TimeStamp
02/07/2013 3:58:01 PM
02/07/2013 3:58:15 PM
02/07/2013 3:58:55 PM
02/07/2013 3:59:01 PM
02/07/2013 3:56:30 PM


HELP?!
0
Comment
Question by:callstate
  • 2
4 Comments
 
LVL 11

Expert Comment

by:David Kroll
ID: 38865129
try

select * from tblhistory where convert(varchar, timestamp, 101) = "02/07/13"

EDIT:

I failed to see that you're in access, so you might have to try this:

select * from tblhistory
WHERE timestamp >= #2013-02-07# and Licenses.Entereddate < #2013-02-08#
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 38865315
Since it is Access, use:

SELECT * from tblHistory
WHERE DateValue([TimeStamp]) = Date()
0
 

Author Closing Comment

by:callstate
ID: 38865404
Perfect!
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38865443
BTW,

I would get out of the habit of calling it a [TimeStamp] as that has a very specific meaning in SQL Server.  I use [LastModified]
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

12 Experts available now in Live!

Get 1:1 Help Now