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

Formatting variables

Status
Not open for further replies.

JazzLeg

Programmer
Aug 22, 2002
63
GB
Hi,

I have date stored in a variable,
its value is '13/09/2002 15:31:47'

I would like to format it to '130902153147'.

Basically removing the '/' and ':' and a few characters.

I would also like to extract the first letter out of a character string, and put in lowercase.

e.g. 'Info' to 'i'

Thanks
 
you can use the replace function for all of these.
-this is for Tarwn-
Replace(expression, find, replacewith[, start[, count[, compare]]]) [lol]

so
var = '13/09/2002 15:31:47'
var = Replace(var, "/", "")
var = Replace(var, ":", "")
or just (for spaces also)
var = Replace(Replace(Replace(var, ":", ""), "/", ""), " ", "")

this is the best I could do with the first character lower casing
javascript would be much easier to due this function unless I'm forgetting
something that I shouldn't be forgetting
str = "Information"
Set RegEx = New RegExp
With RegEx
.Pattern = "I"
.IgnoreCase = True
.Global = True
End With
alert RegEx.Replace(str, "i")
Set RegEx = nothing

of course this is not really that good due to all the I's becoming i's then.
admin@onpntwebdesigns.com
 
or more simply put

variable="Info"
startletter=left(variable,1)
wholeword= LCase(startletter) & Mid(variable, 2)
response.write wholeword
 
Yeah, but the function definition was pretty :) The three most dangerous things in the world are a programmer with a soldering iron, a hardware type with a program patch, and a user with an idea
-computer saying (Wiz Biz - Rick Cook)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top