parsting string date...

# Thread: parsting string date...

1. Senior Member
Join Date
Dec 1969
Posts
1,570

## parsting string date...

hello all.<BR><BR>I am trying to pick apart a string that is filled with the current date. I need the two-digit month, two-digit day, and the two-digit year out of the string!!<BR><BR>date_string = date()<BR><BR>Say the date is 01/01/2003, how would I go about splitting this up into the string 010103. I am guessing that the split function will be used, but I can&#039;t find any solid examples on how to do this exactly. Any assistance would be grand!!<BR><BR>Thanks...<BR>

2. Senior Member
Join Date
Dec 1969
Posts
1,765

## Just a guess

Dim strDay<BR>Dim strMonth<BR>Dim strYear<BR><BR>strDay = Day(date_string)<BR>strMonth = Month(date_string)<BR>strYear = Year(date_string)

3. Senior Member
Join Date
Dec 1969
Posts
1,944

## RE: parsting string date...

Dim myString<BR>Dim myArray<BR>Dim I<BR><BR>MyString = "10/10/02"<BR>MyArray = split(MyString,"/")<BR><BR>For I=0 to Ubound(MyArray)<BR> Response.write MyArray(I)<BR>Next<BR>

4. Senior Member
Join Date
Dec 1969
Posts
1,570

## RE: parsting string date...

The thing is, is that MyString from your example would need to be equal to date() or the current date, and that function uses a four-digit year, which I need to be a two-digit year. Any ideas? I should be able to cut the first two digits off the year with some string manipulation, I just don&#039;t know exactly how to do so!!

5. Member
Join Date
Dec 1969
Posts
52

## RE: parsting string date...

Dim strDay <BR>Dim strMonth <BR>Dim strYear <BR><BR>strDay = Day(date_string) <BR>strMonth = Month(date_string) <BR>strYear = right(Year(date_string),2)

6. Senior Member
Join Date
Dec 1969
Posts
1,765

## Hmmm......Michael H. has picked up my slack!

A little copy, paste, edit, ...., always does the job!<BR><BR><BR><BR>LOL

7. Senior Member
Join Date
Dec 1969
Posts
1,570

## One more thing...

One last thing, and thanks alot for the help everyone, but if the date is say January; the date() will only show 1, instead of 01, and the same goes for if the day of the month is a single digit-#, it will on show that one digit-day. Is there a way manipulate that with using the date(), or should I just use a conditional saying that if one-digit month or one-digit-day, put a zero in front of that digit?

8. Member
Join Date
Dec 1969
Posts
52

## RE: Hmmm......Michael H. has picked up my slack!

Next time I&#039;ll give you credit in the footnotes.

9. Member
Join Date
Dec 1969
Posts
52

## RE: One more thing...

What is your reason for needing it this way?

10. Senior Member
Join Date
Dec 1969
Posts
1,765