![]() |
|
|
|||||||
![]() |
ASP Net - Converting a String to a Date in VB.Net |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Posts: n/a
|
Hi,
This seems quite simple but I don't know what I am doing wrong. I have a string as "15122004" I want to convert this to a date. I have Option Strict On. How can I convert this string to a date in format ("dd/mm/yyyy") without turning off Option Strict? Thanks. |
|
|
|
#2 |
|
Posts: n/a
|
CG wrote:
> Hi, > > This seems quite simple but I don't know what I am doing wrong. > > I have a string as "15122004" > > I want to convert this to a date. > > I have Option Strict On. > > How can I convert this string to a date in format ("dd/mm/yyyy") > without turning off Option Strict? > > Thanks. in C# syntax, but this should be easily convertible: string myDateString = "15122004"; DateTimeFormatInfo myDTFI = new DateTimeFormatInfo(); myDTFI.ShortDatePattern = "ddMMyyyy"; DateTime dt = DateTime.Parse(myDateString, myDTFI); Hans Kesting |
|
|
|
#3 |
|
Junior Member
Join Date: Dec 2007
Posts: 14
|
Dim strDate As String
Dim objdate As Date strDate = "11301982" strDate = strDate.Substring(0, 2) & "/" & strDate.Substring(2, 2) & "/" & strDate.Substring(4, 4) objdate = Date.Parse(strDate).ToShortDateString lbl_Test.Text = objdate ![]() |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Give you enough string functions in Java web reporting tool | freezea | Software | 0 | 10-08-2009 08:03 AM |
| Java String Problems | rbnbenjamin | General Help Related Topics | 0 | 02-03-2009 10:02 PM |
| Hidden linebreaks in string? VB.NET | Jiggy | Software | 0 | 04-23-2008 01:18 PM |
| Need help in converting a String to int | techie | General Help Related Topics | 1 | 11-24-2007 04:27 PM |
| requesting a hand up - read for your Mom [short message with Quotes] | Miss Marple | DVD Video | 1 | 03-17-2005 09:07 PM |