?
Solved

SQL time/date query?

Posted on 2011-03-16
4
Medium Priority
?
289 Views
Last Modified: 2012-05-11
Can someone help me to figure out how to configure this query to pull results by a date range?

a.AppDate between 1/1/2010 AND 12/31/2010

a.AppDate is a smalldatetime (2004-01-09:00:00)

Thanks
SELECT a.FName, a.LName, a.Gender, a.Race, d.Disposition, j.JID, j.JobTitle 
FROM [HRJobPost].[dbo].[Applicant] a, [HRJobPost].[dbo].[Job] j, [HRJobPost].[dbo].[Disposition] d 
WHERE a.AID = d.AID AND a.AppDate = 2004-01-09:00:00 ORDER BY a.LName

Open in new window

0
Comment
Question by:Ahelbling
[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
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:LeDaouk
ID: 35147938
a.AppDate between 1/1/2010 00:00:00 AND 12/31/2010 23:59:00
0
 

Author Comment

by:Ahelbling
ID: 35147971
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '00'.

SELECT a.FName, a.LName, a.Gender, a.Race, d.Disposition, j.JID, j.JobTitle
FROM [HRJobPost].[dbo].[Applicant] a, [HRJobPost].[dbo].[Job] j, [HRJobPost].[dbo].[Disposition] d
WHERE a.AID = d.AID AND a.AppDate between 1/1/2010 00:00:00 AND 12/31/2010 23:59:00 ORDER BY a.LName
0
 

Author Comment

by:Ahelbling
ID: 35147982
This seems to work, no?

SELECT a.FName, a.LName, a.Gender, a.Race, d.Disposition, j.JID, j.JobTitle
FROM [HRJobPost].[dbo].[Applicant] a, [HRJobPost].[dbo].[Job] j, [HRJobPost].[dbo].[Disposition] d
WHERE a.AID = d.AID AND year(a.AppDate) = 2010 ORDER BY a.LName
0
 
LVL 4

Accepted Solution

by:
LeDaouk earned 2000 total points
ID: 35147985
a.AppDate between '1/1/2010 00:00:00' AND '12/31/2010 23:59:00'
you forgot the '' for the date
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Suggested Courses

764 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