Link to home
Start Free TrialLog in
Avatar of jana
janaFlag for United States of America

asked on

SQL scrip to extract decimal portion from a value

We need to extract the decimal value from a result; that is where the result is 2.4574, I want to have the decimal value of .4574.to work with.   We need this with any result; for example:

result of 5.2584, we need .2584
result of 11.3582, we need .3582
result of   6.9884, we need .9884
result of   0.635, we need .635

In essence, in order to give more infor of what's needed, we need to work with the excess of period of years.  For example:

subtract 02/01/2008 from 07/07/2010, and you get 887 days, divide that by 365, you get 2.430136986.

We need to extract and work with the decimal portion of .430136986.




ASKER CERTIFIED SOLUTION
Avatar of JayConverse
JayConverse
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of cyberkiwi
cyberkiwi
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or you could convert it to a string and use the right() runction
Try:
Replace(varValue -fix(varValue),"0","",1,1)
Avatar of Mike McCracken
Mike McCracken

Another idea

(Value MOD 365) / 365

mlmcc
Avatar of jana

ASKER

Hi can you guys give an example with a sql script for  these

{value} - round({value},0)
somevalue - floor(somevalue)
right() runction
Replace(varValue -fix(varValue),"0","",1,1)
(Value MOD 365) / 365
LOL.  We already did!
Avatar of jana

ASKER

i meant with a "SELECT", etc. ... (sorry)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jana

ASKER

Hi the "fix" part didn't work, but all others worked excellently.

One last related question, since we need for excess of a period of year, the decimal value,, can we use something directly on the script for dates?  For example:

if start year is 4/15/2009 and ending year is 7/7/2010, the years passed is 14.93333333.  Is there way to calculate it directly on the dates?  (extract the .9333333 with some sort date function)


SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jana

ASKER

yea sorry about, i meant 1.24444.  The 14.93333333 was the month pass.
"Hi the "fix" part didn't work"
This is for sql (access)!
Avatar of jana

ASKER

thanx all