Discussion:
Round up or down to nearest 5, but not 10
(too old to reply)
Ryan Fisher
2013-02-25 19:25:45 UTC
Permalink
Hello,
This might seem rather odd request, but I have a set of spatial corrdinates in a database with the degrees, minutes and seconds in separate fields. We need to identify the center of each 10 minute block that the location falls within. So what I'm trying to do is develop a query that takes the minutes field (anything between 0 and 59) and rounds the number up or down to 5 (e.g., if 12 then it rounds it up to 15, if 18 then rounds it down to 15, if 22 then 25, etc..). I'm really in the dark on this one!
Thanks for any help!
Ryan
Ron Weiner
2013-02-26 01:42:19 UTC
Permalink
Post by Ryan Fisher
Hello,
This might seem rather odd request, but I have a set of spatial corrdinates
in a database with the degrees, minutes and seconds in separate fields. We
need to identify the center of each 10 minute block that the location falls
within. So what I'm trying to do is develop a query that takes the minutes
field (anything between 0 and 59) and rounds the number up or down to 5
(e.g., if 12 then it rounds it up to 15, if 18 then rounds it down to 15, if
22 then 25, etc..). I'm really in the dark on this one! Thanks for any help!
Ryan
If it were me, rather than to attempt writing a Function, I'd do it by
creating a new table with two Columns (Degree & RoundedDegree).
Pipuklate the table with 60 rows (0 to 59) in the Degree Column and the
(pre)computed value in the Rounded Degree Column.

Now your query can get the rounded result by using a simple Inner Join
on your existing table and the new table. Easy Peasy:-)

Rdub
Ron Weiner
2013-02-26 01:43:41 UTC
Permalink
Post by Ron Weiner
Post by Ryan Fisher
Hello,
This might seem rather odd request, but I have a set of spatial
corrdinates in a database with the degrees, minutes and seconds in separate
fields. We need to identify the center of each 10 minute block that the
location falls within. So what I'm trying to do is develop a query that
takes the minutes field (anything between 0 and 59) and rounds the number
up or down to 5 (e.g., if 12 then it rounds it up to 15, if 18 then rounds
it down to 15, if 22 then 25, etc..). I'm really in the dark on this one!
Thanks for any help! Ryan
If it were me, rather than to attempt writing a Function, I'd do it by
creating a new table with two Columns (Degree & RoundedDegree). Pipuklate
the table with 60 rows (0 to 59) in the Degree Column and the (pre)computed
value in the Rounded Degree Column.
Now your query can get the rounded result by using a simple Inner Join on
your existing table and the new table. Easy Peasy:-)
Rdub
Sheesh...
Pipuklate = Populate

Rdub

Loading...