Can anyone help with the diference I am getting when running these two queries. I have a duration field that is stored in miliseconds which I am trying to convert - but the deurations come out different if I use CONVERT or CAST.
SELECT dbo.actuals.TaskId,
dbo.actuals.Who,
CONVERT(varchar(2),FLOOR(dbo.actuals.Duration / 3600000)) + ':' + CONVERT(varchar(2),(FLOOR(dbo.actuals.Duration / 3600000 - FLOOR(dbo.actuals.Duration / 3600000)) * 60)) AS Duration,
dbo.actuals.JournStart,
dbo.actuals.JournEnd,
dbo.tasks.TaskName
FROM dbo.actuals INNER JOIN
dbo.mans ON dbo.actuals.Who = dbo.mans.Who INNER JOIN
dbo.tasks ON dbo.actuals.TaskId = dbo.tasks.TaskId
WHERE dbo.tasks.TaskName like '%liaison%'
ORDER BY dbo.actuals.JournStart DESC,
dbo.tasks.TaskName DESC
TaskId Who Duration Start End TaskDetail
278 706 1:0 28/04/2006 28/04/2006 Research / Liaison
291 19 0:0 28/04/2006 28/04/2006 Research / Liaison
278 706 1:0 28/04/2006 28/04/2006 Research / Liaison
279 706 0:0 28/04/2006 28/04/2006 Research / Liaison
286 21 0:0 28/04/2006 28/04/2006 Research / Liaison
265 21 0:0 28/04/2006 28/04/2006 Customer Liaison
SELECT dbo.actuals.TaskId,
dbo.actuals.Who,
CAST(FLOOR(dbo.actuals.Duration / 3600000) AS varchar(2)) + ':' + CAST(FLOOR((dbo.actuals.Duration / 3600000 - FLOOR(dbo.actuals.Duration / 3600000)) * 60) AS varchar(2)) AS Duration,
dbo.actuals.JournStart,
dbo.actuals.JournEnd,
dbo.tasks.TaskName
FROM dbo.actuals INNER JOIN
dbo.mans ON dbo.actuals.Who = dbo.mans.Who INNER JOIN
dbo.tasks ON dbo.actuals.TaskId = dbo.tasks.TaskId
WHERE (dbo.tasks.TaskName LIKE '%liaison%')
ORDER BY dbo.actuals.JournStart DESC, dbo.tasks.TaskName DESC
TaskId Who Duration Start End TaskDetail
278 706 1:57 28/04/2006 28/04/2006 Research / Liaison
291 19 0:57 28/04/2006 28/04/2006 Research / Liaison
278 706 1:0 28/04/2006 28/04/2006 Research / Liaison
279 706 0:42 28/04/2006 28/04/2006 Research / Liaison
286 21 0:40 28/04/2006 28/04/2006 Research / Liaison
265 21 0:30 28/04/2006 28/04/2006 Customer Liaison
SELECT dbo.actuals.TaskId,
dbo.actuals.Who,
CONVERT(varchar(2),FLOOR(dbo.actuals.Duration / 3600000)) + ':' + CONVERT(varchar(2),(FLOOR(dbo.actuals.Duration / 3600000 - FLOOR(dbo.actuals.Duration / 3600000)) * 60)) AS Duration,
dbo.actuals.JournStart,
dbo.actuals.JournEnd,
dbo.tasks.TaskName
FROM dbo.actuals INNER JOIN
dbo.mans ON dbo.actuals.Who = dbo.mans.Who INNER JOIN
dbo.tasks ON dbo.actuals.TaskId = dbo.tasks.TaskId
WHERE dbo.tasks.TaskName like '%liaison%'
ORDER BY dbo.actuals.JournStart DESC,
dbo.tasks.TaskName DESC
TaskId Who Duration Start End TaskDetail
278 706 1:0 28/04/2006 28/04/2006 Research / Liaison
291 19 0:0 28/04/2006 28/04/2006 Research / Liaison
278 706 1:0 28/04/2006 28/04/2006 Research / Liaison
279 706 0:0 28/04/2006 28/04/2006 Research / Liaison
286 21 0:0 28/04/2006 28/04/2006 Research / Liaison
265 21 0:0 28/04/2006 28/04/2006 Customer Liaison
SELECT dbo.actuals.TaskId,
dbo.actuals.Who,
CAST(FLOOR(dbo.actuals.Duration / 3600000) AS varchar(2)) + ':' + CAST(FLOOR((dbo.actuals.Duration / 3600000 - FLOOR(dbo.actuals.Duration / 3600000)) * 60) AS varchar(2)) AS Duration,
dbo.actuals.JournStart,
dbo.actuals.JournEnd,
dbo.tasks.TaskName
FROM dbo.actuals INNER JOIN
dbo.mans ON dbo.actuals.Who = dbo.mans.Who INNER JOIN
dbo.tasks ON dbo.actuals.TaskId = dbo.tasks.TaskId
WHERE (dbo.tasks.TaskName LIKE '%liaison%')
ORDER BY dbo.actuals.JournStart DESC, dbo.tasks.TaskName DESC
TaskId Who Duration Start End TaskDetail
278 706 1:57 28/04/2006 28/04/2006 Research / Liaison
291 19 0:57 28/04/2006 28/04/2006 Research / Liaison
278 706 1:0 28/04/2006 28/04/2006 Research / Liaison
279 706 0:42 28/04/2006 28/04/2006 Research / Liaison
286 21 0:40 28/04/2006 28/04/2006 Research / Liaison
265 21 0:30 28/04/2006 28/04/2006 Customer Liaison