Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return all records after a decimal place

Status
Not open for further replies.

MadMax7

MIS
Feb 17, 2004
62
GB
I have a table full of deciaml hrs.

I need to be able to return all data from the right of the decimal place (if there is any decimal minutes if not return nothing) so that i can multiply the decimal minutes by 60 to give me true minutes

Hope someone can help...


 
Hi, you could do something like this:


Dim intHours as integer


intHours = Cint(RIGHT(<Your_Field>, Len(<Your_Field>) - Instr(<Your_Field>, '.')))

Basically, you're taking the length of the field, and subtracting the position of the decimal (and then retrieving everything to the right of it).


HTH,

Doc Tree
 
data from the right of the decimal place
[field name] - Int([field name])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
drTree

thankyou for the speedy response it works fine for returning the minutes i have tried using the code to show the hrs by simply changeing the Right ar the start to left, but when i do this if there is a single hr (9.75) then it returns 9. is ther any way of is not showing the decimal place after the number
 
It is not clear what the field contains. i.e. data type etc..

Assuming a decimal field with the whole number being the hours and the decimal part the fractional part of an hour.
For example 2.8 being 2 hours and 8/10ths of an hour or 48 minutes.

Csng((2.8 * 60) Mod 60)
 
h=9.75
? Int(h)
9
? h - Int(h)
0.75

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top