PDA

View Full Version : Data in Double datatype



kbsudhir
10-21-2008, 12:00 PM
Hi All,

I want have a data "7.4896" is a double datatype.
I want to capture just ".4896" i.e. data in decimals. How to do this...??

Please guide

Sudhir

CreganTur
10-21-2008, 12:17 PM
Right("7.4896",Len("7.4896")-InStr(1,"7.4896",".") + 1)

Just change all the instances of "7.4896" to your variable.

Explination:

The above code takes the length of your string and subtracts it by the number of characters (from the left) until the designated character is encountered- in this case a period. I increase the length by 1 so that the period is included in the returned result.

6 total characters
-2 characters to encounter period
+1 character to include the period in returned result
So, it grabs the right 5 characters, which are: .4896

Demosthine
10-21-2008, 04:34 PM
Good Afternoon.

There are two other solutions. Depending on whether you will be using negative numbers or not, you may want to compare the Fix Function to the Int Function. They will return different results with negative values.

Cell A1
7.4896

Cell A2
=A1-Int(A1)

What this does is it takes the value of A1 (7.4896) and it subtracts just the Integer portion of A1 (7). This will result in a value of 0.4896.

Hope this helps.
Scott