## How can I round up the time to the nearest X minutes?

Is there a simple function for rounding UP a DateTime to the nearest 15 minutes? E.g. 2011-08-11 16:59 becomes 2011-08-11 17:00 2011-08-11 17:00 stays as 2011-08-11 17:00 2011-08-11 17:01 becomes 2011-08-11 17:15 15 Answers 15

## How do you round a float to 2 decimal places in JRuby?

How do you round a float to 2 decimal places in JRuby(1.6.x)? number = 1.1164 number.round(2) # The above shows the following error # wrong number of arguments (1 for 0) 6 Answers 6

## Rounding up to the nearest multiple of a number

OK – I’m almost embarrassed posting this here (and I will delete if anyone votes to close) as it seems like a basic question. Is this the correct way to round up to a multiple of a number in C++? I know there are other questions related to this but I am specficially interested to … Read more

## How to round a Double to the nearest Int in swift?

I’m trying to make a calculator of growth rate (Double) that will round the result to the nearest Integer and recalculate from there, as such: let firstUsers = 10.0 let growth = 0.1 var users = firstUsers var week = 0 while users < 14 { println(“week \(week) has \(users) users”) users += users * … Read more

## Truncate (not round) decimal places in SQL Server

I’m trying to determine the best way to truncate or drop extra decimal places in SQL without rounding. For example: declare @value decimal(18,2) set @value = 123.456 This will automatically round @value to be 123.46, which is good in most cases. However, for this project, I don’t need that. Is there a simple way to … Read more

## Round to 5 (or other number) in Python

Is there a built-in function that can round like the following? 10 -> 10 12 -> 10 13 -> 15 14 -> 15 16 -> 15 18 -> 20 19 Answers 19

## Python 3.x rounding behavior

I was just re-reading What’s New In Python 3.0 and it states: The round() function rounding strategy and return type have changed. Exact halfway cases are now rounded to the nearest even result instead of away from zero. (For example, round(2.5) now returns 2 rather than 3.) and the documentation for round: For the built-in … Read more

## How to get a float result by dividing two integer values using T-SQL?

Using T-SQL and Microsoft SQL Server I would like to specify the number of decimal digits when I do a division between 2 integer numbers like: select 1/3 That currently returns 0. I would like it to return 0,33. Something like: select round(1/3, -2) But that doesn’t work. How can I achieve the desired result? … Read more