• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

ASP String Split Question With Date

I have what I think might be an easy one, but it's driving me mad.

I'm trying to split this date on the " "
Here's the date:  "11/14/2009 1:00:00 PM "

Below is the code that I'm using - for some reason I can only get the first value when I call the array that I've created using START_TIME(0)

I'm really in a bind, and need to split the date above, pull out the actual time and remove the extra :00 from the end of it.

I'm awarding extra points because I'm up against a wall. THanks!!
dim pre_start 
pre_start = rs("BEGIN_DATE_TIME")
START_TIME = Split(pre_start)

Open in new window

0
NJguy
Asked:
NJguy
  • 3
  • 3
1 Solution
 
_DanElliottCommented:
You have to pass the space as the second param to the split function.
dim pre_start 
pre_start = rs("BEGIN_DATE_TIME")
START_TIME = Split(pre_start, " ")
 

Open in new window

0
 
NJguyAuthor Commented:
Sorry - just tried to edit this - it's the same either way (with the START_TIME = Split(pre_start, " ") or without the space in quotes) - I can get the first part but not the second part of the array.

Also, it should be said that START_TIME(0) works properly, and just brings up 11/14/2009
0
 
_DanElliottCommented:
Are you sure you are getting the full "11/14/2009 1:00:00 PM " into pre_start?  The reason I ask is because with the code below, it writes out 1:00:00...
dim pre_start 
pre_start = "11/14/2009 1:00:00 PM"
START_TIME = Split(pre_start, " ")
response.write start_time(1)

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
NJguyAuthor Commented:
That's where I'm running into the issue - if I do a response.write of the field from my SQL database I'm seeing the full "11/14/2009 1:00:00 PM" - I tried to find a string command to convert it to text or something thinking that there was an issue coming from SQL....

But yep - the date that I copied above is what I get when  directly response.write out the pre_start variable.


0
 
_DanElliottCommented:
If pre_start has the full string "11/14/2009 1:00:00 PM" in it (I think you are saying it does), then the code below should work...Note the 1 in START_TIME(1)
dim pre_start 
pre_start = "11/14/2009 1:00:00 PM"
START_TIME = Split(pre_start, " ")
response.write start_time(1)

Open in new window

0
 
NJguyAuthor Commented:
THANKS FOR THE HELP - I was in a bind, and sort of fat fingered it. APPRECIATE IT MUCH!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now