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
 date issue

Author  Topic 

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-07-07 : 02:39:09
when I use convert(datetime,inv_date,111) it is giving me err saying

the conversion of the char datatype to a datetime data type resulted in an out-forange datetime value.

inv_date has values like '23/11/2006' stored as varchar datatype,
I want to bring these values to a another table which has correspounding col data type as datetime.


isdate('23/11/2006') is giving 0 value


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-07 : 02:40:27
DD/MM/YYYY is 103
convert(datetime,inv_date,103)



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-07-07 : 02:47:49
Thanks now it is working however
what If I do not want the time part in this, as the original table was not having time part

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-07 : 02:53:11
if you are using datatime data type, the date and time are together in same column. Unless you are using SQL 2008 you can have date and time separately as with date data type and time data type.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-07-07 : 05:02:26
see these links for formatting dates

http://www.sql-server-helper.com/tips/date-formats.aspx
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=80563
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-07 : 05:15:47
quote:
Originally posted by aakcse

Thanks now it is working however
what If I do not want the time part in this, as the original table was not having time part




If you want to show data in front end application, do formation there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-08 : 12:30:54
quote:
Originally posted by aakcse

Thanks now it is working however
what If I do not want the time part in this, as the original table was not having time part




try to pass date values in iso format always (yyyyy-mm-dd hh:mm:ss)
also for formatting try to apply functions available at front end as Madhi suggested
Go to Top of Page
   

- Advertisement -