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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql Date conversion

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-06-15 : 08:24:53
priya writes "select convert(smalldatetime,'09/06/2006') is working

select convert(smalldatetime,'13/06/2006') it shows an error
The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.

why it shows an error"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-06-15 : 08:26:54
It's assuming an American date format (mm/dd/yyyy) but your dates are British format (dd/mm/yyyy). The first conversion succeeded but it returned the wrong date. Try this:

select convert(smalldatetime,'13/06/2006', 103)
select convert(smalldatetime,'09/06/2006', 103)
Go to Top of Page
   

- Advertisement -