Last post Apr 27, 2010 09:06 AM by zoggling
Apr 22, 2010 05:16 PM|zoggling|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 05:46 PM|mbanavige|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 05:47 PM|ignatandrei|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 09:06 AM|zoggling|LINK
Thank you for your replies, apologies for the late response. The first solution worked for me, thank you!