Solved

Problem with sql query

Posted on 2009-07-10
9
154 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
  • 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
 

Author Comment

by:tornadog
ID: 24826984
actually this is the query select expdt from table1 where expdt >getdate()-1
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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 59

Accepted Solution

by:
Kevin Cross earned 500 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 59

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

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

Suggested Solutions

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.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

12 Experts available now in Live!

Get 1:1 Help Now