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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 smalldatetime

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-05-21 : 05:46:10
declare @ValueDate smalldatetime
set @ValueDate = '21/05/2007'
select @ValueDate

error:
The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.

Please note, if '05/21/2007' is used then there is no error.
How is it possible to get 'dd/mm/yyyy' as above to work please?
Thanks

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-21 : 05:49:15
always use ISO format to specify the date string. Using MM/DD/YYYY or DD/MM/YYYY is depending on your language locale settings.


declare @ValueDate smalldatetime
set @ValueDate = '20070521'
select @ValueDate



KH

Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-05-21 : 05:52:22
quote:
Originally posted by khtan

always use ISO format to specify the date string. Using MM/DD/YYYY or DD/MM/YYYY is depending on your language locale settings.


declare @ValueDate smalldatetime
set @ValueDate = '20070521'
select @ValueDate



KH




hello
How do I convert my date '21/05/2007'
to the format you suggest?
Thanks
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-21 : 05:57:40
Where is the source of input for the date 21/05/2007 ?

You can use convert() to convert to datetime

select @ValueDate = convert(datetime, '21/05/2007', 103)



KH

Go to Top of Page
   

- Advertisement -