Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 27, 2010 01:06 PM by zoggling
Apr 22, 2010 09:16 PM|LINK
I have searched a few pages on this (including MSDN) but have not quite reached a solution. I need to convert "16/04/2010 22:39:06" to "2010-04-16 22:39:06.034" (for example).
I have already written an SQL function to do this, but would rather do this in VB.NET if possible. The date value is coming from the Date Created information of a newly uploaded file:
tbNewDateCreated.Text = MyFileInfo.CreationTime
Thanks in advance!
Convert date time format vb.net
Apr 22, 2010 09:46 PM|LINK
Since the CreationTime property of a FileInfo object is a DateTime, you can use the DateTime.ToString method to control how the date converts to a string.
tbNewDateCreated.Text = MyFileInfo.CreationTime.ToString("yyyy-MM-dd HH:mm:ss.fff")
Apr 22, 2010 09:47 PM|LINK
dim dt as DateTime= DateTime.ParseExact("16/04/2010 22:39:06","dd/MM/yyyy HH:mm:dd",Nothing)
dim s as string= dt.ToString("yyyy-MM-dd HH:mm:dd")
Apr 27, 2010 01:06 PM|LINK
Thank you for your replies, apologies for the late response. The first solution worked for me, thank you!