Results 1 to 7 of 7

Thread: Parsing Date

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2004
    Posts
    48

    Parsing Date

    Hey all,
    I need to create a date format that is 8/15/2004 but without the "/"'s. This is the code i'm using to get the date as it is now.

    VB Code:
    1. theTime.Now.ToShortDateString()

    That gives me 7/31/2004, but how do I take out the /'s. Anyone know how to do that.

    Cran56

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Can't you do something like this:
    Dim myString As String
    myString = DateTime.Now.ToShortDateString()
    myString = myString.Replace("/", "")


    I haven't loaded up VS or anything to verify it, but it might get you close.

  3. #3
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    or you might try

    dim MyDate as string = format(Now,"MMddyyyy")

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Duh...lol, thanks for pointing that out.

    You can get rid of the format function call and just use the overloaded .ToString() method:

    mystring = DateTime.ToString("MMddyyyy")

  5. #5
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    LOL - there is always a better way!

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Originally posted by hellswraith
    Duh...lol, thanks for pointing that out.

    You can get rid of the format function call and just use the overloaded .ToString() method:

    mystring = DateTime.ToString("MMddyyyy")
    Does not work for me because

    "Reference to a non shared member requires an object reference"
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  7. #7
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    hello taxes. i guess, just a small error. as hellswraith has no vs to play with. it's
    VB Code:
    1. dim s as string=datetime.now.tostring("MMddyyyy")

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