Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

spliting number into 2 fields (before and after decimal)???

Featured Replies

Hi All

Can anyone help me.

I want to divide a number (in another field) into 2 new fields. One holding the part of the number before the decimal and another containing only the 2 digits after the decimal.

Have no problem with the first part but if I use a calculation with Round (number; precision) to get the part after the decimal it works fine as long as the number doesn't end with .00

When the number ends with .00 it takes the to digits before the decimalpoint instead of the to zeros after the decimalpoint...

example

This works

number = 1025.95

firste part ok = 1025

second part ok = 95

This doesn't

number = 1025.00

first part ok = 1025

second part fail = 25

Have also tried with truncate instead of round and combinations of both but with no luck...

Also tried to multiply the number with 1.0001 to get a number I knew had more decimals but... still same result.

Any help would be great

Best regards

The Dog

Edited by Guest

Grab integer:

Int(numberfield)

Grab remainder and remove decimal point:

Substitute(Mod(numberfield, 1), ".", "")

  • Author

Hi John

Thanks for your reply

Tried making a field with the calculation

(Field=)

Substitute(Mod(ORDRE::TOTAL, 1), ".", "")

But I get an error telling me that the field does not exist.

Found out that there were 2 "," that needed to be changed to ";"

So now I'm using

(Field=)

Substitute(Mod(ORDRE::TOTAL, 1); "."; "")

and it works fine. But I still have a little problem.

It only shows 5 if the remaining decimals is .50

Would like it to show to digits everytime.

As if

.50 = 50

.05 = 05

.25 = 25

So I still need a little help.. Sorry ;o)

Best regards

The Dog

Edited by Guest

Try this, for the remainder:

Middle ( GetAsText ( number ) ; Position ( GetAsText ( number ); "." ; 1 ; 1 ) + 1 ; 2 )

Note that this calc works with FM8...

the GetAsText function may have another name in FM6 (now I don't remember)

The simplest way is to format the field's display as decimal number with fixed 2 decimal digits. You can do this by selecting the field in Layout mode, and choosing Format > Number... from the menu.

If, for some reason, you need this as a calculation, you have to round the number first. Because 1.996 should come out as 2.00. Rounding also makes it easier to extract the remainder:

Int ( Round ( Number , 2 ) )

& "." &

Right ( "00" & Round ( Number , 2 ) * 100 , 2 )

  • Author

Hi raybaudi

Thanks for your tip.

But there is no GetAsText in filemaker 6.. ;-(

Hi comment

he has an international copy of FM6, so ',' must be changed into ';'

try something as:

NumberToText..

  • Author

Hi Comment

It solved my problem... Thanks a lot..

and to raybaudi Thanks too..

Good.

BTW, Daniele: most of the time, you don't need to convert data type explicitly. Filemaker does that for you on-the-fly, so for example:

Position ( number ; string ; 1 ; 1 )

is automatically interpreted as:

Position ( GetAsText ( number ) ; string ; 1 ; 1 )

without you having to write it out.

Same goes for setting the result type of a calculation. For example, try a calculation of Get (CurrentDate), but set the result to Number.

Then see what happens with MonthName (732444).

Edited by Guest

Thank you comment

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.