September 4, 2009 at 3:22 pm
I have a numeric filed and want to convert into minute and see.
September 4, 2009 at 8:18 pm
You need two functions. One converting the numerical number into standard datetime type, then use DATEPARTfunction to get time.
September 4, 2009 at 9:35 pm
I wouldn't use DATEPART to get the time... you'd have to use it more than once depending on what the expected return would be.
Of course, we don't actually know what the numeric "field" contains nor what the format of the expected time result is, so it's all pure speculation on our part.
MAK... can you be a little bit more clear on the gazinta's?
--Jeff Moden
Change is inevitable... Change for the better is not.
September 5, 2009 at 10:16 am
I am a numeric filed,
column I want to change to time
0 0:00:00
900000000 0:15:00:00
1800000000 0:30:00:00
2700000000 0:45:00:00
After that I want add these into date and get date and time combine.
September 5, 2009 at 12:19 pm
Replace the ",0" in the DATEADD with the WHOLE date you want to add the time to.
SELECT DATEADD(mi,d.NumericTime/3600000000*60,0)
FROM --This must makes the test data
(SELECT 0 AS NumericTime UNION ALL
SELECT 900000000 UNION ALL
SELECT 1800000000 UNION ALL
SELECT 2700000000) d
--Jeff Moden
Change is inevitable... Change for the better is not.
September 5, 2009 at 12:45 pm
Ummm... your original request said "minutes", but the following will give you seconds, as well.
SELECT DATEADD(ss,d.NumericTime/3600000000.0*3600,0)
FROM --This must makes the test data
(SELECT 0 AS NumericTime UNION ALL
SELECT 900000000 UNION ALL
SELECT 1800000000 UNION ALL
SELECT 2710000000) d
--Jeff Moden
Change is inevitable... Change for the better is not.
September 5, 2009 at 12:48 pm
And... don't use the following unless you can tolerate up to a second of error...
SELECT DATEADD(ss,d.NumericTime/1000000.0,0)
FROM --This must makes the test data
(SELECT 0 AS NumericTime UNION ALL
SELECT 900000000 UNION ALL
SELECT 1800000000 UNION ALL
SELECT 2710000000) d
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply