Solved

SQL query to pull today's transactions

Posted on 2013-02-07
4
165 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

785 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