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

Add text to string 2

Status
Not open for further replies.

Brianfree

Programmer
Feb 6, 2008
220
0
0
GB
Hi is it possible to add text to a position in a string ie..

I have the following value in a field "199407" and i want to change it to "1994.07"

Kindest thanks,

Brian
 
Code:
UPDATE table
SET column = Left(column, Len(column) - 2)
  + '.' + Right(column, 2)

Something like this should work.

--John [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
Thanks for a fast reply can this be done "on the fly" or will i have to use an update statment?

Many thanks!

Brian
 
Sorry! just figured it out from your example!

Many thanks,


Brian
 
Thought i had a winner, however if the field is null i get an error message...

Left(Vehicles.Start_Date,Len(Vehicles.Start_Date)-2)+'.'+Right(Vehicles.Start_Date,2) AS Expr1

can i modify this so it only does this to a field if it is not null?

Many thanks!

Brian
 
In that case, try the Stuff function.

Code:
Stuff(Vehicles.Start_Date, 5, 0, '.') As Expr1

If vehicle.start_date is null, then Expr1 will be null.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top