Solved

SQL time/date query?

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

726 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