December 5, 2006 at 4:15 pm
Is there a way to get the following to return the seconds as 2 digits??
SELECT DATEPART(ss, '2003-11-17 09:08:05.223')
currently it returns 5 but I need to pad it with a 0. Any suggestions??
Thanks,
Veronica
December 5, 2006 at 4:43 pm
SELECT right(convert(varchar(8), cast('2003-11-17 09:08:05.223' as datetime), 108), 2)
December 5, 2006 at 5:35 pm
select REPLACE(STR(5, 2), ' ', '0')
"5" is a result of your DATEPART function.
_____________
Code for TallyGenerator
December 6, 2006 at 3:19 pm
I'm not saying that this is any fster or better, but just another alternative:
Right(
'0' + Cast(datepart(ss, '2003-11-17 09:08:05.223') As varchar(2)), 2)
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply