Parsing an ugly time string into clean datetime value
Posted on 2006-07-07
I am working on a data conversion for a client and I need to convert a string column in an access database to a datetime column in a sql database. We are not using the date portion of this field so it doesnt matter, but i need the time to be accurate. I am hoping that someone will know of a nice, comprehensive routine to convert these ugly strings to nice times. I'll give some examples of the data that I have to convert:
"8","900","930","915AM","1030AM","9.15AM","9:30am0","9:00am,","9;00--","9;00AM4","90045AM" (this one may just need to be dropped), "9 00 am". The DateTime.Parse routine in .NET can handle some of these cases but definitely not all.
Please help me so I dont have to spend hours and hours coming up with a routine to deal with all these different cases.
Thanks in advance.