Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - SQL Server 2005/Yukon
 DateTime Format Problem in Query
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

2 Posts

Posted - 03/08/2007 :  06:36:31  Show Profile
My MaintenanceLog table has an entry with following data in a row.
Name: Toney Mirra
ActualDateTime: 2007-02-16 12:55:02.867
PlannedDateTime: 2008-12-05 20:08:57.000
Comments: Sample Entry

But when I run the following query it doesnt return any value.
I think there is some problem in DateTime format. Can anyone help me fixing this?

select Comments from MaintenanceLog where
ActualDateTime = '2/16/2007 12:55:02 PM' and
PlannedDateTime = '12/5/2008 8

In (Som, Ni, Yak)

17689 Posts

Posted - 03/08/2007 :  07:06:42  Show Profile

select Comments 
from   MaintenanceLog 
where  ActualDateTime  = '20070216 12:55:02.867'
and    PlannedDateTime = '20081205 20:08:57.000'


Edited by - khtan on 03/08/2007 07:07:24
Go to Top of Page

Flowing Fount of Yak Knowledge

5581 Posts

Posted - 03/08/2007 :  07:06:43  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message
Obviously, it's not going to return any record since you are not considering millisecond part in your WHERE clause.

Harsh Athalye
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000