Solved

SQL time/date query?

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

830 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