Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply

ASP Net - Converting a String to a Date in VB.Net

 
Thread Tools Search this Thread
Old 12-29-2004, 12:25 PM   #1
=?Utf-8?B?Q0c=?=
 
Posts: n/a
Default Converting a String to a Date in VB.Net

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.
  Reply With Quote
Old 12-29-2004, 12:43 PM   #2
Hans Kesting
 
Posts: n/a
Default Re: Converting a String to a Date in VB.Net

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


  Reply With Quote
Old 05-29-2008, 08:47 PM   #3
fred5152
Junior Member
 
Join Date: Dec 2007
Posts: 14
Default

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

fred5152 is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47