Skip to content
Advertisement

Tag: rounding

Round to nearest 15 minute interval

I’ve seen this question asked and answered for time that is stored as a date, but I have duration of hours and minutes stored as numeric(4,2). For example 2.12, is 2 hours 12 minutes. I need to round that to the nearest 15 minute interval, doing this (CONVERT([numeric](4,2),round(2.12/(25),(2))*(25))) doesn’t work because it’s base 10 and rounds time incorrectly. Any help

Always round set seconds / minutes /hours to 00 mysql

In my database I have the following date-times: I want to be able to retrieve these records with the hours, minutes or seconds set to their 00 values: For example I want to be able to return records with seconds and milliseconds set to 00: Or return them setting the minutes to zero as well. How can I write a

How to have exact decimal values without rounding in MySQL

I have this SQL script below: What I expect like result is: 72.39. I don’t want to round the number. if I use the select round(72.396, 2) the result I get is: 72,40 How can I have what I expect without rounding using Mysql? Answer You need to use the truncate function instead of round: To answer the question in

Dividing by decimal values – rounding issue

I’m trying to divide two decimal values, in hope they will return the following; 1.132930. However, SQL appears to be rounding the value to 1.132931. The value returned before conversion is 1.1329305135951. The SQL code i’m using is as follows: Answer You can round the value before the cast as following:

Advertisement