Date compares between App display and Database Storage

I was working on a script yesterday and came accross a challenge I hadn't encountered yet in my automation scripting adventures.

The page I was working on displays the dates of various status changes for the objects under test.  So for example there were two dates on the page.  One associated with when the object was created and the second was when the object status changed.

And seeing as I have a strong manual QA background I thought...I can validate those dates NO problem.  I know where they are stored in the DB and I can just compare them using QTP's table checkpoint procedures. (Which I've TOTALLY taken to btw)

When I started investigating this, I found a small problem.  The Database stores the date like this:  2007-05-21 14:51:00 but the Application is going to display that date like 5/21/2007.

So..what's an automation engineer to do? 

Well..First I pinged my buddy who used to work at this company with me and we keep in touch via IM pretty consistently.  He had several suggestions, the first of which was try to try the FormatDateTime VBscript command. 

Now granted this solution does have a weakness...if your localization settings are changed for some reason this may not work b/c FormatDateTime uses your PC's locale settings to determine date formats.

However, since I have total control over the machines these scripts are running on I can set the Shortdate format on the PC to be the format I need it to be in to convert the date into a useful format.

So I used this function FormatDateTime to convert the SQL date into the shortDate, stored it out into the DataSheet and then used the QTP tablecheckpoint to confirm the date in the App was correct.

Easy Peasy, Lemon Squeezy!

<YAY!>   <cheers for her bud's genius>

«June»
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567