Detecting the correct time

I had an issue today where a data feed was sending dates in an inconsistent format and this was playing havoc with importing that data into the database. I needed a way of telling if the data received was in the correct format.

What ever way you look at it dates are a nightmare because when you read a date it will be different depending on where you are from. 12/05/2014, today’s date the 12th of May, for our US cousins will read the 5th of December!

Add in that sometimes you will get a date with the time included and this can be in 24 format or 12 hours you can see how complex this really is.

In this case the application that was sending me data couldn’t even make it’s own mind up which format they were using. As the data was being delivered as a string my SQL import was balking on some of the rows.

What I needed was a way of checking the validity of the data before I pushed it into the SQL table.

Rule No. 1 when writing a script is to use Google. It could save you a lot of time. here’s what I found, so I didn’t have to do any hard lifting at all 🙂



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.