Solved

SQL time/date query?

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Creating and Managing Databases with phpMyAdmin in cPanel.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

746 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

10 Experts available now in Live!

Get 1:1 Help Now