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
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
260 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
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with SQL joins 9 53
SQL Server Degrading on Write 13 70
SQL 2005 - Memory Table Column Names 11 75
why sql server only update some statistics in the database ? 3 32
Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

792 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