Last post Nov 13, 2018 06:51 PM by limno
Nov 13, 2018 06:23 AM|binustrat|LINK
In my procedure i am writing query to find sum of minutes
if sum(minutes)> 59 i dividing by 60 means sum(minutes)/60
else i need to show this as minutes means
if sum(minutes) is 15 then i need show as 0.15, how its possible
how concatenate 0. with sum(15)?
below my giving my query
case when sum(t2.OT)> 59 then sum(t2.OT/60) else '00.'+ CONVERT(VARCHAR, sum(t2.OT)) end AS OverTime
when i use this query getting below error
Error converting data type varchar to float.
Nov 13, 2018 06:43 AM|oned_gk|LINK
Try this CASE WHEN ... THEN varcharvalue ELSE anothervarcharvalue END
Nov 13, 2018 06:51 PM|limno|LINK
You can use datetime to format it. Here is an example:
declare @minutes int=135
Select Format(dateadd(minute, @minutes,0),'hh:mm') as 'hh:mm'