convert date format from sql server

Posted by Krishnasamy2008 under Sql Server on 2/19/2011 | Points: 10 | Views : 1544 | Status : [Member] | Replies : 3
HI friends,
How to convert this format 2011-02-18T17:34:52.1742107+05:30 to 02/18/2011 17:34:52 PM or 02/18/2011 17:34:52 AM


Thanks and regards,
Krishna.K




Responses

Posted by: Tripati.patro on: 2/19/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Try this link if you want to change in the query.
http://www.sql-server-helper.com/tips/date-formats.aspx

B.Tripati Patro
Oracle Certified Associate

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 2/21/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
you can write ur own custom function for this and use it.

Thanks and Regards
Madhu

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 2/21/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Try this...

Declare @date Varchar(max)
Set @date = '2011-02-18T17:34:52.1742107+05:30'
Set @date = Substring(@date, 1, CharIndex('.', @date) -1)
select Convert(DateTime, Convert(Varchar(25), @date, 126))


output: 2011-02-18 17:34:52.000

Cheers :)


Thanks,
T.Saravanan

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response