Solved

How to write a query using the field dtRequested which is defined as type varchar using SQL Server 2005?

Posted on 2013-05-23
1
261 Views
Last Modified: 2013-05-23
I am trying to run a query against a SQL Server 2005 table that has a field titled dtRequested defined as varchar(500) with values such as:

8/8/2005
May 24 2005 12:00AM

Do you know how I could write a query using a WHERE clause in which I can retrieve
records where dtRequested is > 12/31/2011. In other words, I want records with dates
for years 2012 and 2013 only.

I tried the following query but it doesn't pull in records with dtRequested values greater than '12/31/2011'.

My query is as follows:

SELECT dev AS Developer, userNameF + ' ' + userName AS 'User', appname AS 'Application Name', dtRequested AS 'Date Requested', changeRequest AS Request, reason AS Reason,
tSOXSignOFF.dtUsrSignOff
FROM tSOXUsrRequest LEFT OUTER JOIN tSOXSignOFF ON
tSOXUsrRequest.reqID = tSOXSignOFF.reqID
WHERE (tSOXSignOFF.usrSignOff='Yes') and devid='zimmermj'
and dtRequested > '12/31/2011'
0
Comment
Question by:zimmer9
[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
1 Comment
 
LVL 25

Accepted Solution

by:
Ron Malmstead earned 500 total points
ID: 39191163
SELECT dev AS Developer, userNameF + ' ' + userName AS 'User', appname AS 'Application Name', dtRequested AS 'Date Requested', changeRequest AS Request, reason AS Reason,
tSOXSignOFF.dtUsrSignOff
FROM tSOXUsrRequest LEFT OUTER JOIN tSOXSignOFF ON
tSOXUsrRequest.reqID = tSOXSignOFF.reqID
WHERE (tSOXSignOFF.usrSignOff='Yes') and devid='zimmermj'
and CAST(dtRequested as DateTime) > '12/31/2011'
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

740 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