Split or len

T

Tim:..

Hi

I have a bunch of dates I want to split into year, month, day and time variables

EG
2004-04-27TO08:00:0

I know how I can do this with 'len' but I think it is an inefficent way of doing it
var=var+
for i=0 to 9
sDayTime(var,i) = mid(sNodes(node,0),len(sNodes(node,0))-10
sDate(var,i) = left(sDayTime(var,i),len(sDayTime(var,i))-9
sTimeSec(var,i) = mid(sDayTime(var,i),len(sDayTime(var,i))- 7
sTime(var,i) = left(sTimeSec(var,i),len(sTimeSec(var,i))- 3
nex

I thought I could use 'split' to do the same thing but all my years end up in one variable all my months end up in another etc et

EG
myArray(0) = 20042005200
myArray(1) = 03040
myArray(2) = 26282

I guess it is because my loop is incorrect

How do I break it up so all my years, months or days are something like below

year(0) = 200
year(1) = 200
year(2) = 200
etc

...::This is my split code::.

'An example value for sNodes(node,0) is 2004-04-27TO08:00:0

dim myString, myArray,
DateTime = sNodes(node,0
myArray = Split(DateTime, "-"
for i = lbound(myArray) to ubound(myArray
Response.Write(myArray(i) & "<br />" & vbCrLf
nex

Thanks for any help
 
C

CJM

Have a look at the Day(), Month(), Year() functions.

Index of VBScript functions:
http://www.devguru.com/Technologies/vbscript/quickref/vbscript_list.html

Chris

Tim:.. said:
Hi,

I have a bunch of dates I want to split into year, month, day and time variables.

EG:
2004-04-27TO08:00:00

I know how I can do this with 'len' but I think it is an inefficent way of doing it!
var=var+1
for i=0 to 99
sDayTime(var,i) = mid(sNodes(node,0),len(sNodes(node,0))-10)
sDate(var,i) = left(sDayTime(var,i),len(sDayTime(var,i))-9)
sTimeSec(var,i) = mid(sDayTime(var,i),len(sDayTime(var,i))- 7)
sTime(var,i) = left(sTimeSec(var,i),len(sTimeSec(var,i))- 3)
next

I thought I could use 'split' to do the same thing but all my years end up
in one variable all my months end up in another etc etc
 
P

Phill. W

Tim:.. said:
I have a bunch of dates I want to split into year, month, day and time
variables. eg: 2004-04-27TO08:00:00

If /all/ your nodes are in the /same/ format, you can validly make
assumptions about /where/ things are, as in

sTemp = sNodes( node,0 )
sDayTime( var,i ) = Mid( sTemp, 10, 10 )
sDate( var,i ) = Mid( sTemp, 1, 10 )
sTimeSec( var,i ) = Mid( sTemp, 19, 2 )
sTime( var,i ) = Mid( sTemp, 13, 8 )

or something close to that, anyway.

HTH,
Phill W.
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top