Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem with sql query

Posted on 2009-07-10
9
Medium Priority
?
160 Views
Last Modified: 2012-05-07
I am running this simple query

select expdt from table1 where expdt > '7/9/2009'
expdt is a datetime field
this is the output I am getting;




Jul  1 2009 11:55PM
Jul  1 2009 11:55PM
Jul  1 2009 11:55PM
Jul  1 2009 11:55PM
Jul  1 2009 11:55PM
Jul  1 2009 11:55PM
Jul  1 2009 11:55PM
Jul  1 2009 11:55PM
Jul  2 2009  9:25AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  6 2009 12:00AM
Jul  7 2009 12:00AM
Jul  7 2009 12:00AM
Jul  7 2009 12:00AM
Jul  7 2009 12:00AM
Jul  7 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  8 2009 12:00AM
Jul  9 2009 12:00AM
Jul  9 2009 12:00AM

Open in new window

0
Comment
Question by:tornadog
[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
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 9

Expert Comment

by:wellhole
ID: 24826936
what do you get when you run
select expdt from table1 where expdt > '2009-07-09'
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24826937
select expdt from table1 where expdt > '2009-07-09'
0
 

Author Comment

by:tornadog
ID: 24826948
same result, still printing everything from July 1
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Author Comment

by:tornadog
ID: 24826984
actually this is the query select expdt from table1 where expdt >getdate()-1
0
 
LVL 9

Expert Comment

by:wellhole
ID: 24827011
try using DATEADD(day,-1,GETDATE())
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24827019
>CONVERT(varchar, GETDATE()-1,112)
0
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 2000 total points
ID: 24827033
what is your data type of column
select expdt 
from table1 
where expdt >= dateadd(d, -1, datediff(d, 0, getdate()))

Open in new window

0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 24827040
Forget the question, I see you said it is datetime.
0
 

Author Closing Comment

by:tornadog
ID: 31602256
worked nicely. Would never would have figured that one.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

721 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