|
Request: Convert String "10000110101345" into currency format like "$100001101013.45".
Solution:
SELECT "$"+ Left( "10000110101345", InStr( "10000110101345",Right( "10000110101345",2))-1)+"."+Right( "10000110101345",2) as Dollar, InStr( "10000110101345",Right( "10000110101345",2)) as pos, Right( "10000110101345",2) as Desimal, "10000110101345" as textTot;
Now let us summarize the String functions in the MS Access.
- Len(string)
Len(string) returns the number of characters in the string. You can specifiy the string itself in quotation marks, or you can speciy the field that contains the text string.
Sample: Len("Northwind") returns 9
- Left(string, length)
Left(string,length) returns a specified number of characters from the left side of a string.
Sample: Left("Northwind",5) returns "North"
- Right(string, length)
Right(string, length) returns a specified number of characters from the right side of a string
Sample: Right("Northwind",4) returns "wind"
- InStr ([start],string1, string2 [, compare])
InStr([start,] string1, string2[, compare]) returns a number specifying the position of the first occurrence of one string within another.
- start is optional, and it is a number that specifies the position of the character where you want to begin searching. For example, if start is 3, the search begins at the third letter in the string.
- string1 is the string, or the field containing the string that you are searching in.
- string2 is the string, or the field containing the string, that you are searching for.
- compare is optional, and it determines how the InStr function compares string1 and string2. The default comparison type is binary and therefore case-sensitive.
Samples:
- InStr(1, "Northwind", "r") returns 3
- InStr("Northwind", "r") returns 3
- InStr("Northwind", "x") returns 0
- InStr("Northwind", "wind") returns 6
- InStr("Chester Zhang", "") returns 8
Reference site: FontStuff - ACCESS TIPS
<><
|