Convert String to Date

jliz2803

Newcomer
Joined
May 17, 2006
Messages
8
How would I go about converting a string to a date: I have this

Code:
Dim Dat as DateTime

Dat = Date.FromOADate(6/03/06)

but this always returns 8:00:00AM
how do I get it to return 6/03/06 as a date I am doing this because I want to be able to add one day onto this value, I also do not know how to do that. Any suggestions? Thanks
 
I got it converted to Date with the Basic CDate conversion gosh I'm an idiot, does anyone know how to add 1 day to this value though?
 
Oh my god.

You realize that 6/03/06 is not a string.
"6/03/06" is a string.

Use DateTime.Parse
 
My goodness, gracious, great balls of fire.

VB also has support for DataTime literals if that helps. Instead of quotes you can use number signs...
Visual Basic:
Dim TheThirtyFirstOfMayInNineteenNinetyThree As DateTime = [COLOR=Red]#5/31/1993#[/COLOR]
And just to point out...
Posting Guidelines said:
Posts should be posted in the proper forum
A post like this, which really has nothing to do with ASP.NET should really go in the general section. Also, it would do you a lot of good to check the object browser, intellisense, MSDN, or do a quick google before posting here so that you don't find yourself answering your own questions this way on a public forum.
 
Back
Top