hello,
-1469
-5776
-2952
-6790
-815
-2486
24
3922
NULL
-323
-1023
148
I am trying to convert this int into time, but it is not working properly. I need in -hh:mm:ss or HH:MM:SS formate.
hello,
-1469
-5776
-2952
-6790
-815
-2486
24
3922
NULL
-323
-1023
148
I am trying to convert this int into time, but it is not working properly. I need in -hh:mm:ss or HH:MM:SS formate.
Welcome to the microsoft TSQL Q&A forum!
If there is a minus sign, it cannot be converted to time format.
Time range 00:00:00 through 23:59:59.997
Unless the minus sign is removed.
For more details, please refer to:
datetime (Transact-SQL)
If you have any question, please feel free to let me know.
Regards
Echo
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hi Eco,
You cleared my doubt, I am trying to convert that since long time. Thank You.
hello,
I used *
'select CAST(DATEADD(second, column / 100 * 60 + column % 100, 0) AS time)
from table
*'
for positive time and it working successfully and resulted as timespan . but, not for negative.
hello,
Thanks for the answer
But, I need that in timeformate, it resulted as varchar.
The time datatype does not seem to support negative values. Maybe you should keep your durations as numbers. Interpret or convert them when needed depending on circumstances.
13 people are following this question.