February 2, 2011 at 9:28 am
Hi,
I have the following integer 80010, All I want to do is convert this to
08:00:10 so I can use in a DateDiff function.
Is there a time function which will do this or do I have to resort to breaking the number down and appending the ':'?
Thanks 🙂
February 2, 2011 at 9:39 am
Maybe:
DECLARE @time int, @dt datetime;
SET @time = 80010;
SET @dt = DATEADD(second, 80010%100,DATEADD(minute, 80010%10000/100,DATEADD(hour, 80010/10000,'19000101')));
SELECT @dt
February 2, 2011 at 10:07 am
Thanks.
I already have a date in a different column and I trying to calculate the number of minutes worked by an employee on a given date. I have the starttime as 80010 (integer) and endtime as 161500. The result I am looking for is 495 minutes. I believe I can achieve this result if I was able to convert startdate 80010 to 08:00:10 and endate to 16:15:00 and then using the datediff function to get the results in minutes.:-)
February 2, 2011 at 10:56 am
Why bother with functions?:
DECLARE @starttime int = 80010
,@endtime int = 161500
SELECT ((@endtime/10000 * 60) + (@endtime%10000/100))
- ((@starttime/10000 * 60) + (@starttime%10000/100))
February 2, 2011 at 11:04 am
Thanks:-)
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply