Wednesday, November 20, 2013

date time formatting

Try this:



DECLARE @DateTimeValue varchar(32)
set @DateTimeValue = '20101211124624'


SELECT
convert(varchar, convert(datetime, substring(@DateTimeValue,0,9), 111))
+ ' ' + substring(@DateTimeValue, 10, 2)
+ ':' + substring(@DateTimeValue, 12, 2)
+ ':' + substring(@DateTimeValue, 14, 2)





Regards Harsh


No comments:

Post a Comment