Jump to content

Recommended Posts

Posted

I am using SQL Server 2000.

when I am querying data from following query it gives an error.

Query: select * from SaleMain where dateinfo='2008-02-25'

error: Server: Msg 242, Level 16, State 3, Line 1

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

And occour the same error for : select * from SaleMain where dateinfo=cast('2008-02-25' as datetime)

But when I am using this query it works:

select * from SaleMain where dateinfo=cast('2008-02-24 00:00:00.000' as datetime)

And then I try this query and works fine:* select * from SaleMain where dateinfo=cast('2008-02-25' as datetime)

And also this query works after that: select * from SaleMain where dateinfo='2008-02-25'

Actually I am amazed with this functionality. And I have experience in this type of adhoc behavior for datetime in earlier also.

Can anyone please tell me, is there any sure and a very accurate way*of writing these type of queries those are using datetime values.

:)

 

 

 

More...

 

View All Our Microsoft Related Feeds

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...