Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 31, 2009 06:28 AM by Bober Song - MSFT
Member
460 Points
615 Posts
Aug 27, 2009 07:08 PM|LINK
I need to convert this string "09122009" to a date 09/12/2009
How do I do this in vb.net
Contributor
3421 Points
575 Posts
Aug 27, 2009 08:00 PM|LINK
DateTime MyDateTime = DateTime.ParseExact(09122009,"dd/MM/yyyy",null)
All-Star
15176 Points
3304 Posts
Aug 27, 2009 08:01 PM|LINK
Aug 28, 2009 12:18 PM|LINK
I get the same erroe. "The date is invalid"
3400 Points
616 Posts
Aug 28, 2009 12:32 PM|LINK
DateTime MyDateTime = DateTime.ParseExact(09122009,"MMddyyyy",null)
Aug 28, 2009 02:24 PM|LINK
I still get "String was not recognized as a valid DateTime."
Aug 28, 2009 03:52 PM|LINK
156 Points
57 Posts
Aug 29, 2009 05:24 AM|LINK
try
Date dateObject = new Date(StringObject.Substring(5,4),StringObject.Substring(3,2), StringObject.Substring(1,2))
DateTime string to date create date date
Aug 29, 2009 08:35 AM|LINK
solution:
Dim theCultureInfo As IFormatProvider = New System.Globalization.CultureInfo("en-GB", True)
Dim theDateTime As DateTime = Convert.ToDateTime(DateTime.ParseExact("09122009", "ddMMyyyy", theCultureInfo)).ToString("dd/MM/yyyy")
34 Points
15 Posts
Aug 29, 2009 09:44 AM|LINK
Use this :
strDate="09122009"
DateTime strNewDate = DateTime.Parse(strDate.ToString()).ToString("dd/MM/yyyy");
helixpoint
Member
460 Points
615 Posts
convert string to date
Aug 27, 2009 07:08 PM|LINK
I need to convert this string "09122009" to a date 09/12/2009
How do I do this in vb.net
Helixpoint LLC
Mobile Marketing
inquisitive_...
Contributor
3421 Points
575 Posts
Re: convert string to date
Aug 27, 2009 08:00 PM|LINK
DateTime MyDateTime = DateTime.ParseExact(09122009,"dd/MM/yyyy",null)
while(1)
suthish nair
All-Star
15176 Points
3304 Posts
Re: convert string to date
Aug 27, 2009 08:01 PM|LINK
My Blog
helixpoint
Member
460 Points
615 Posts
Re: convert string to date
Aug 28, 2009 12:18 PM|LINK
I get the same erroe. "The date is invalid"
Helixpoint LLC
Mobile Marketing
NihirPorecha
Contributor
3400 Points
616 Posts
Re: convert string to date
Aug 28, 2009 12:32 PM|LINK
DateTime MyDateTime = DateTime.ParseExact(09122009,"MMddyyyy",null)
My blog
helixpoint
Member
460 Points
615 Posts
Re: convert string to date
Aug 28, 2009 02:24 PM|LINK
I still get "String was not recognized as a valid DateTime."
Helixpoint LLC
Mobile Marketing
suthish nair
All-Star
15176 Points
3304 Posts
Re: convert string to date
Aug 28, 2009 03:52 PM|LINK
My Blog
shashiupc25
Member
156 Points
57 Posts
Re: convert string to date
Aug 29, 2009 05:24 AM|LINK
try
Date dateObject = new Date(StringObject.Substring(5,4),StringObject.Substring(3,2), StringObject.Substring(1,2))
DateTime string to date create date date
suthish nair
All-Star
15176 Points
3304 Posts
Re: convert string to date
Aug 29, 2009 08:35 AM|LINK
solution:
Dim theCultureInfo As IFormatProvider = New System.Globalization.CultureInfo("en-GB", True)
Dim theDateTime As DateTime = Convert.ToDateTime(DateTime.ParseExact("09122009", "ddMMyyyy", theCultureInfo)).ToString("dd/MM/yyyy")
My Blog
hellobiswa20...
Member
34 Points
15 Posts
Re: Simply use this
Aug 29, 2009 09:44 AM|LINK
Use this :
strDate="09122009"
DateTime strNewDate = DateTime.Parse(strDate.ToString()).ToString("dd/MM/yyyy");
By : Biswa