Results 1 to 5 of 5

Thread: Split Date

  1. #1

    Thread Starter
    Fanatic Member Redth's Avatar
    Join Date
    May 2001
    Location
    Ontario, Canada
    Posts
    551

    Split Date

    Hello
    I've made it so in my app, the user selects the day, month and year from drop down menus... this works great for adding dates to the database.. however, when they pull up a record to edit, i'd like the date to go to that record's date.. so here's what im trying to do...

    newdate() = split(thedate, "/")

    i get an error doing that...

    is there some special thing i need to do to the variable holding the date before splitting it? i declared the variable as a string b4 putting the date into it from the database (the database field isn't even a Date type field.. just normal varchar)....

    the split function works nice for everything else .. help's appreciated!

  2. #2
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    don't declare it as a string
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    You shouldn't have any problem using strings. This works.
    Code:
    Dim newdate() As String
    Dim thedate As String
    
    thedate = "06/04/02"
    newdate() = Split(thedate, "/")
    
    Debug.Print newdate(0)
    Debug.Print newdate(1)
    Debug.Print newdate(2)

  4. #4
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    oh sorry, my mistake... i didn't see the () after the declaration (if you don't have that it won't work right??)
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Maybe I missed something but how is something like this:
    VB Code:
    1. newDateYear=Year(thedate)
    2. newDateMonth=Month(thedate)
    3. newDateDay=Day(thedate)
    4. 'or to join parts
    5. thedate=DateSerial(newDateYear,newDateMonth,newDateDay)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width