Mario,

If you know the field is a cerain length you can "cast" it as a char:
CAST(myNumField, Char(6)), then use substring( ) to concatenate it:

DECLARE @myString char(6)
DECLARE @myTime char(8)

SELECT @myString = (SELECT CAST(myNumField, Char(6))  FROM table where
..... )

SELECT @myTime = LEFT(@mySTring,2) + ':' + SUBSTRING(@myString,3,2) + ':' +
RIGHT(@myString,2)


You could do this within a query (without the declaritive syntax) by casting
3 times:


SELECT LEFT(CAST(myNumField, Char(6)),2) + ':' + SUBSTRING(CAST(myNumField,
Char(6)),3,2) + ':' + RIGHT(CAST(myNumField, Char(6)),2)

        AS myTimeString  FROM mytable

If you are using SQL 2000 you can create a UDF scalar function and use it
in-line.

-mk


-----Original Message-----
From: Mario Martinez [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 03, 2002 9:30 AM
To: CF-Talk
Subject: TSQL


Hi folks:
This question could be innapropiate but this list has always been great .
Besides I'm a newbie.
My problem is Transact-SQL related. I want to convert a numeric value (it 's
the amount of seconds a user has spend in one of my sites) to this format
hh:mm:ss .Is there any function in SQL transact that I could use ??. Any
piece of advice should be appreciated.
regards
Mario


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

Reply via email to