Skip to content
Advertisement

Rounding of hours in sql queries

The values ​​you see below are loaded with a query and they are related to a time stamp. What they ask me to insert is a rounded value; up and down. Rounding must be done at minutes of 15 and 30.

If the round is set to 15 and the marking has been made at 7:59, it is rounded off to 8:00 if the marking is at 8:01 am rounded to 8:15 am, as do I implement this thing within this query?

Query:

Values:

If the state is equal to < Ingresso > it is rounded up to the top if the status is < Uscita > is rounded down, for example 07:59 becomes 08:00 whereas if it is 17:44 it becomes 17:45

Advertisement

Answer

The Logic is much more simple than described, perhaps. Try this approach:

EDIT: Applied logic to your own query

SQLFiddle here:

http://sqlfiddle.com/#!18/475202/1
http://sqlfiddle.com/#!18/23d16/13

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement