Related Posts

Archive

Dates in VB.net + MySQL

June 2nd, 2008

For reasons I can’t go into, I was asked to write a Windows service in Microsoft Visual Studio 2005, in VB.NET 2.0.

What I need to do was parse one gate format, “06242005″, to MySQL’s format, “2005/06/24″.

Apparently, to do this correctly, you need to specify some sort of culture, and all that is defined in an include:

Imports System.Globalization

Now, since I might want to alter this date at some point, I’ll be creating a temporary DateTime to hold it in.

Dim date As String = DateTime.ParseExact(oldDate, "MMddyyyy", CultureInfo.InvariantCulture).ToString("yyyy/MM/dd")

More detail on the formatting strings is here.

-Sud.

Posted in SQL, Technical, VB.NET |

Comments are closed.

Previous post: Add a network printer in Windows Server 2008

Next Post: Updating ‘validate-one-required’ in Prototype.js Dexagogo validation