July 23, 2009 at 10:56 am
Comments posted to this topic are about the item GetDateTime Function
July 30, 2009 at 7:45 am
Hi,
Try this instead, works just as well. Basically I insert a space between the Date and the time and a : between the hours and the minutes
declare @DtStr varchar(20)
set @DtStr='200907011020'
select convert(datetime,substring(@DtStr,1,8)+' '+substring(@DtStr,9,2)+':'+substring(@DtStr,11,2))
July 30, 2009 at 9:58 am
Ummm... CONVERT is relatively expensive and so are all of the substrings not to mention the use of a UDF...
SELECT CAST(STUFF(STUFF('200907111400',11,0,':'),9,0,' ') AS DATETIME)
--Jeff Moden
Change is inevitable... Change for the better is not.
July 30, 2009 at 11:18 am
tks to all. both suggestions are good.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply