[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

convert str to int

Posted on 2006-07-20
10
Medium Priority
?
837 Views
Last Modified: 2008-02-26
hi,

Please assist how can we convert str to integer?

Select cast(Column1 as Int) From MyTable

Thanks.
0
Comment
Question by:RyanBank
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 17147805
SELECT CInt(Column1) FROM MyTable
0
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 1000 total points
ID: 17147807
SELECT VAL(Column1) FROM MyTable
0
 
LVL 66

Accepted Solution

by:
Jim Horn earned 1000 total points
ID: 17147811
CLng() converts to Long Integer
CStr() converts to String
CDate() converts to Date
CBool() converts to Boolean
CCur() converts to Currency
CDbl() converts to Double

...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 33

Expert Comment

by:hongjun
ID: 17147829
this will do

Select CInt(Column1) From MyTable
0
 
LVL 33

Expert Comment

by:hongjun
ID: 17147832
so fast!
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 17147847
(Off Topic)  <Frazier Crane> When you know the answer, it's hard not to hit the buzzer...
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17148144
Ryan, is your data likely to contain nulls or letters?

I say this because VAL converts

Null becomes #Error
123ABC becomes 123
ABC123 becomes 0


Not sure what the conversion functions (as Jim as explained) might return. It may be a data type mismatch (no offence Jim)

So you need to cater for this scenario, thats if u are likely to have them

to stop nulls from falling over, u can wrap field with NZ

VAL(NZ(field,0))

gives a null value to 0, but u can specify what u want


0
 
LVL 16

Expert Comment

by:Chuck Wood
ID: 17148978
Ryan,

Just for your information, the C in CInt, CStr, CDate, etc. stands for Cast. I noticed you are familiar with cast.

Chuck
0
 
LVL 44

Expert Comment

by:GRayL
ID: 17149503
Chuck:  VB Editor, Help, Answer Wizard, type - Conversion Functions - and you get all the conversion functions where specifically it talks about "coercing" one datatype to another.  Type in - Cast - and you get an entirely different set of returns, none of which are 'Conversion Functions'  - for what it's worth.
0
 
LVL 16

Expert Comment

by:Chuck Wood
ID: 17149537
GRayL: I was reading a discussion of these functions in VB.Net and it said that the C was used to "cast" the variable into a different type. Sorry I don't remember where I saw that. In any case, it doesn't matter as cast and convert are fairly synonymous. For those used to cast in  other languages, perhaps it is helpful for them to think in terms of cast instead of convert. Thanks for your input.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question