Having difficulty converting a decimal value to a time value and I was wondering if someone could help me

I runa stored procedure which populates a table containing all the information about each student and what classes they attend. I then search this table and work out how many hours each student is in college per day, total breaks per day, total time absent per day and so on

shown below is a snippet of code to show how I get total breaks (get the difference between start time and end time of day = 8 hours then subtract the sum of all the classes that day)
For this example shown in spreadsheet because two classes are timetabled for the same time (which should not happen) the total hours per day is 8 hours and 15 mins giving the result total breaks being -0.250000. I want to keep this as a negative number because the user can easily see that the timetable is wrong but what I would like to do is display the total breaks for this example as -0.15 instead of -0.250000

Thanks in advance

SELECT student_id, Date,week_no, MIN(CONVERT(datetime, start_time)) AS 'Start Time', MAX(CONVERT(datetime, End_Time)) AS 'End Time', ROUND(cast((datediff(mi, MIN(start_time), MAX(end_time)) / 60.0) as FLOAT),2) AS 'Total Hours', (DATEDIFF(minute, MIN(start_time), MAX(end_time)) - SUM(DATEDIFF(minute, start_time, end_time))) / 60.0 AS 'Total Breaks'from allstudents

Your first problem here probably is that floor(0.25) is 0, but floor(-0.25) is -1, you should obtain the absolute value of your data before applying floor function.

I don't remember exactly now, but I think sql server has an ABS function to that?

I was looking at ABS function and it converts all the negatives into postivie values which isn't correct

Any other suggestions

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

IT issues often require a personalized solution. With Ask the Experts™, submit your questions to our certified professionals and receive unlimited, customized solutions that work for you.

## Premium Content

You need an Expert Office subscription to comment.Start Free Trial