Results 1 to 6 of 6

Thread: *not resolved:) * DateTime confusion, help me plz :(

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    *not resolved:) * DateTime confusion, help me plz :(

    I'm simply trying to parse from this date string:
    Thu Oct 10 19:21:45 2002


    I'm just testing it with a simple string, and its not working

    Dim dtfi As New Globalization.DateTimeFormatInfo
    dtfi.LongDatePattern="ddd"
    doing DateTime.Parse("mon", dtfi) will give me an error. It will work if I choose the current day of the week instead of "mon" though. Other than that, I get this error:
    Run-time exception thrown : System.FormatException - String was not recognized as a valid DateTime because the day of week was incorrect.

    someone help me out plz I want to parse from the date string above, but seems like I cant
    Last edited by MrPolite; Oct 18th, 2003 at 07:22 PM.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Not sure. The only way I would approach it would be to spit the string up, then grab the parts out that I need. The problem is your string is not formatted in a normal format. Usually the date is together, but on yours, you have the year after the time....just to much for a parser to handle, and just enough to cause you headaches.

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by hellswraith
    Not sure. The only way I would approach it would be to spit the string up, then grab the parts out that I need. The problem is your string is not formatted in a normal format. Usually the date is together, but on yours, you have the year after the time....just to much for a parser to handle, and just enough to cause you headaches.
    well the "beauty" of .NET is that it allows you to parse from a custom date format but it seems like it's not workign for me plus, I just tried to parse from a simple date like this "mon 11:45" and it wouldnt work (it would only work if I used the current day of the week). There is also a ParseExact method, but I dont know how to use that one either.
    anyone knows how to do this?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    Lively Member
    Join Date
    Aug 2003
    Location
    When?!?!
    Posts
    108

    Your problem is solved

    This is pretty simple, in .NET, they program Thursday to be Thur, not Thu.
    DannyJoumaa
    Advanced VB6 Programmer
    Intermediate-Advanced VB .NET Programmer
    Intermediate C# Programmer
    Intermediate Win32 Developer
    Beginner Mac OS X Developer
    Contact: [email protected]

    Favorite Sayings:
    "Every time you open your mouth, you prove your an idiot."
    "God is a programmer. Satan is a bug. Life is debugging."

  5. #5

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    hmm
    still, I dont know what's wrong, it wouldnt work with other stuff either (like 12:45:30 2003). I'm almost positive it's doable with the parse method, but anyways, I ended up rearranging the date string to match the datetime format and then I used parse
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  6. #6
    Lively Member
    Join Date
    Aug 2003
    Location
    When?!?!
    Posts
    108
    Just parse it the old way
    DannyJoumaa
    Advanced VB6 Programmer
    Intermediate-Advanced VB .NET Programmer
    Intermediate C# Programmer
    Intermediate Win32 Developer
    Beginner Mac OS X Developer
    Contact: [email protected]

    Favorite Sayings:
    "Every time you open your mouth, you prove your an idiot."
    "God is a programmer. Satan is a bug. Life is debugging."

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