TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Saranya Rajendran
NA
53
14k
varchar to datetime conversion in sql 2008
Feb 2 2016 5:42 AM
I need to convert varchar to datetime..I've tried something like following
declare @date varchar(150)='01/10/15'
declare @datenew date
select @datenew=convert(smalldatetime,CONVERT(nvarchar(10), CAST(@date AS DATETIME), 101) ,101)
print @datenew
the output is : 2015-01-10
But when I change the date to
declare @date varchar(150)='13/10/15'
it throws the following error.. :
"The conversion of a varchar data type to a datetime data type resulted in an out-of-range value."
the resultant format of datetime is YYYY-MM-DD. I want the result in the format DD-MM-YYYY..
What do i do..
Thanks in advance
Reply
Answers (
2
)
sql
I am getting error subquery return more than one value