|
-
Nov 23rd, 2008, 01:08 AM
#1
Thread Starter
Fanatic Member
DateTime conversion
How to convert this date format "september 29, 2008 - 13:00:07 " into "9/29/2008 1:00:07 PM"?
Visual Studio.net 2010
If this post is useful, rate it

-
Nov 23rd, 2008, 02:52 AM
#2
Re: DateTime conversion
To convert a string representation of a date into a Date object you call Date.ParseExact or, if there's a chance it might not be valid, Date.TryParseExact. To convert a Date object into a string in a specific format you call ToString and specify that format. MSDN describes all the standard and custom format strings available to you for converting between Strings and Dates in each direction. I'll leave it to you to look that up because it will benefit you to see all of what's available rather than just a single solution to a single problem. Once you've read that documentation you'll never have to ask for a date format again.
-
Nov 24th, 2008, 02:11 AM
#3
Thread Starter
Fanatic Member
Re: DateTime conversion
 Originally Posted by jmcilhinney
MSDN describes all the standard and custom format strings available to you for converting between Strings and Dates in each direction.
yep.. i started referring when this date format banged my head,,.
but immediately i cant get the solution. so went through string manipultaion
anyway thanks jmc..
Visual Studio.net 2010
If this post is useful, rate it

-
Nov 24th, 2008, 03:10 AM
#4
Re: DateTime conversion
Well, as I said, MSDN describes all the custom format strings available so I don't know where you were looking. That original string is "MMMM d, yyyy - HH:mm:ss" and the final string is "M/dd/yyyy h:mm:ss tt". Simple.
-
Nov 24th, 2008, 05:35 AM
#5
Re: DateTime conversion
@vijy - you read this http://msdn.microsoft.com/en-us/library/az4se3k1.aspx and did not find the answer????
Code:
Dim ds As String = "september 29, 2008 - 13:00:07"
ds = ds.Replace("-"c, " "c)
Dim dt As DateTime
dt = DateTime.Parse(ds)
Debug.WriteLine(dt.ToString)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|