Solved

SQL time/date query?

Posted on 2011-03-16
4
287 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 500 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

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!

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

737 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