T
tom
Can someone be so kind as to advise the function that
changes text to numbers? If there is such.
changes text to numbers? If there is such.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Roger said:Depending on what type of number you wanted your text converted to, you'd
use one of these:
CBool() - Boolean
CByte-Byte 0 to 255.
CCur() - Currency
CDate() - Date
CDbl() - Double
CDec() - Decimal
CInt() - Integer
CLng() - Long Integer
CSng() - Single
CVar() - Variant
Roger said:DateTime field IS a number.
SELECT CDate("31111.52421") AS Expr1;
will return:
3/5/1985 12:34:52 PM
SELECT CDate("31111.52421") + 1 AS Expr1;
will return:
3/6/1985 12:34:52 PM
As for IsNumeric, the DateTime datatype is a special case. Even though it
is a number, IsNumeric will return false, probably because most users don't
think of a date as a number
CVAR certainly works in SQL:
SELECT CVar("2.5")+1 AS Expr1;
returns
3.5
The value is held in its original format (text in this case) until a math
operation is performed on it. So simply using the CVar by itself will not
convert the text to numbers, but if you do any math on it, it will. Again,
not the most common case, but it does convert text to a number.
3. CDEC does not in fact work in SQL queries
However, I don't see anything in
the orignal question that specified SQL.
Roger said:DateTime field IS a number. It is a double-precision number where the
integer portion represents the date and the decimal portion represents the
time.
Roger said:Dates ARE numeric (floating-point number).

Just because SQL casts a string into a number correctly when used in a math
expression does not mean that CVar does not.
Roger said:The original poster asked about functions that convert text to numbers. I
gave functions that did so.
This nit-picking is hardly productive use of
either or our time.

Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.