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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Truncate A Number in a Data Grid

Status
Not open for further replies.

cnealy

Programmer
Feb 25, 2002
32
0
0
US
I have a datagrid that displays an age (in years) based on a date of birth (mm/dd/yyyy). The following SQL is the data source for the grid. I want to truncate the Age field such that only the whole number appears, rather than a number with decimals. I tried using Format$ to format the result as "##" - but this rounded the age up or down, rather than giving the actual digits that the query returns.

Public Function ViewSQL(Sort As String) As String
ViewSQL = _
("Select PID, J_Number, " & _
"Juv_First & ' ' & Juv_Last As Name, DOB, " & _
"(DateDiff('m',DOB,Now)/12) As Age " & _
"From tblJuvenile Order by " & Sort)
End Function
 
Solved on my own. Found a function called Int( ) that returns the integer portion of a number.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top