Round down

  • Thread starter Thread starter Emmy
  • Start date Start date
E

Emmy

I need to update a field DOWN to the nearest thousand.
I tried this and it works, but it rounds up.

1000 * ([fieldname] \ 1000)

Ex) 23700 now rounds to 24000. It needs to be 23000.
 
I need to update a field DOWN to the nearest thousand.
I tried this and it works, but it rounds up.

1000 * ([fieldname] \ 1000)

Ex) 23700 now rounds to 24000. It needs to be 23000.

Works fine for me in both VBA and SQL (I get 23000).
 
Thanks!! That worked perfectly.
-----Original Message-----
Hi Emmy,

Did You try
Int([YourField] / 1000) * 1000

--
HTH
Bernd


Emmy said:
I need to update a field DOWN to the nearest thousand.
I tried this and it works, but it rounds up.

1000 * ([fieldname] \ 1000)

Ex) 23700 now rounds to 24000. It needs to be 23000.
.
 
(Value \ 1000) is the same as Int(Value / 1000) so Int(Value \ 1000) should
work just as well, Ken.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Ken Snell said:
sorry... this is what to use:

1000 * Int([fieldname] / 1000)
--

Ken Snell
<MS ACCESS MVP>

Emmy said:
I need to update a field DOWN to the nearest thousand.
I tried this and it works, but it rounds up.

1000 * ([fieldname] \ 1000)

Ex) 23700 now rounds to 24000. It needs to be 23000.
 
Must have been a senior moment....

You're right, of course!

--

Ken Snell
<MS ACCESS MVP>

Douglas J. Steele said:
(Value \ 1000) is the same as Int(Value / 1000) so Int(Value \ 1000) should
work just as well, Ken.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Ken Snell said:
sorry... this is what to use:

1000 * Int([fieldname] / 1000)
--

Ken Snell
<MS ACCESS MVP>

Emmy said:
I need to update a field DOWN to the nearest thousand.
I tried this and it works, but it rounds up.

1000 * ([fieldname] \ 1000)

Ex) 23700 now rounds to 24000. It needs to be 23000.
 
I need to update a field DOWN to the nearest thousand.
I tried this and it works, but it rounds up.

1000 * ([fieldname] \ 1000)

Ex) 23700 now rounds to 24000. It needs to be 23000.

Works fine for me in both VBA and SQL (I get 23000).

I wonder if this is variable with different versions of some DLL or
other?

?(23700 \ 1000) * 1000
23000

Emmy, could you post your *actual* expression (the SQL of the query)
and an example where it rounds up? Which version of Access are you
using?
 
1000 * Int([fieldname] / 1000)

Hi Ken. Actually "\" forces integer division. :-)

I think the question is whether \ *reliably* truncates rather than
rounding. The OP suggested that on her machine it rounds; several of
us have ascertained that (*on our machines*) it truncates.

Int() can be counted upon to truncate, not round.
 
I think the question is whether \ *reliably* truncates rather than
rounding. The OP suggested that on her machine it rounds; several of
us have ascertained that (*on our machines*) it truncates.

Oh yeah said:
Int() can be counted upon to truncate, not round.

I can't argue with that, John. My oversight :-)
 
Back
Top