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

Strip out a portion of a string

Status
Not open for further replies.

jasonsalas

IS-IT--Management
Jun 20, 2001
480
GU
Hi everyone,

I've got a string value that I'm pulling out of a database, which is rendered by the VBScript FORMATDATETIME function:
FormatDateTime(objRS("Date"),1)

The data is, of course, presented like so:
June 12, 2002

But I'd like to display this only as "June 12".

Any ideas? Is there anything in VBScript comparable to JavaScript's Substring method?

Thanks!
 
how about something like

dim str_tempdate
str_tempdate = objRS("Date")
str_tempdate=left(str_tempdate,1, instr(str_tempdate, ",")-1) codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
<insert witticism here>
 
Dim MyString, LeftString
MyString = &quot;June 12, 2002&quot;
LeftString = Left(MyString, 6) ' LeftString contains &quot;June 12&quot;.
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
 
you beet me codestorm. I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
 
Thanks guys. I was actually able to hit it right on the mark with the following:

dateArray = Split(FormatDateTime(Date(),1),&quot;,&quot;)
Response.Write(dateArray(1))
 
...oops...that should have read:

dateArray = Split(FormatDateTime(objRS(&quot;Date&quot;),1),&quot;,&quot;)
Response.Write(dateArray(1))
 
I would have thought it would have been dateArray(0) codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
<insert witticism here>
 
I thought that, too...but Response.Write'ing out the zero-based index of the array returns &quot;Wednesday&quot;.

jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top