Connecting Tech Pros Worldwide Help | Site Map

From String to correct DateTime

Newbie
 
Join Date: Aug 2009
Posts: 2
#1: Aug 7 '09
So, I'm trying to do this...
DatumRodjenja_db = DatumRodjenja.Substring(6, 4) & "-" & DatumRodjenja.Substring(3, 2) & "-" & DatumRodjenja.Substring(0, 2)

Where DatumRodjenja_db is DateTime variable, and DatumRodjenja is String. And even after that, I'm still getting DatumRodjenja_db in this format "DD.MM.YYYY."

The thing is I need date in "YYYY-MM-DD" format because that's how I store it into database.

I suppose this is some kind of problem in CultureInfo but still I can't figure it out...thank you.
Newbie
 
Join Date: Aug 2009
Posts: 4
#2: Aug 7 '09

re: From String to correct DateTime


you will format date in mm/dd/yyyy format and then enter
Newbie
 
Join Date: Aug 2009
Posts: 2
#3: Aug 7 '09

re: From String to correct DateTime


Quote:

Originally Posted by kuldeepjat View Post

you will format date in mm/dd/yyyy format and then enter

Can you explain me how? Because everything I've tried a lot of stuff and didn't find the solution.
thanks
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#4: Aug 7 '09

re: From String to correct DateTime


Use the DateTime's ToString method. Supply the ToString method with a "format string" that specifies how the string should be printed.

Check this out. It gives you a listing of standard date/time format strings.

-Frinny
Newbie
 
Join Date: Jun 2009
Posts: 6
#5: Aug 7 '09

re: From String to correct DateTime


cdate(yourdate).tostring("yyyy/MM/dd")
Reply

Tags
cultureinfo, database, datetime, string, vb.net


Similar Visual Basic .NET bytes