hi guys
i waant to know how to convet the string to date in vb.net ..
i fany body have code please let me know...
sandin
Printable View
hi guys
i waant to know how to convet the string to date in vb.net ..
i fany body have code please let me know...
sandin
there is a CDate() function
there is probably a better way though:D
hi MrPolite
i used that but it doen`t work properly.. could u give me the sample code for easy understanding..
sandin:(
Try this
VB Code:
DateTime.Parse("december 12, 2005").ToShortDateString()
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object _ , ByVal e As System.EventArgs) Handles MyBase.Load Dim datetime As DateTime = Now.Today 'string date MsgBox(datetime.ToString) 'string date converted to date type MsgBox(CDate(datetime)) End Sub
hi guy,
if my string is "20021212" then i want to convert it in Date format
will u plz. tell ?? how??
sandin
is your string always fix-string ??inother words , it contains 8 chara ?
yes , it is 8 chat and a number..
Look at the string in the code and after msgbox is shwon , this means it's converted to date type.
VB Code:
Dim datetime As String = "20021213" datetime = datetime.Insert(4, "/") MsgBox(CDate(datetime.Insert(7, "/")))
You might have to write your own function to convert that format or you can change the format to 2002/12/12, then you can use
VB Code:
MessageBox.Show(DateTime.Parse("2002/12/12").ToLongDateString())