|
We have a PC that runs a script every hour to pull data from an Oracle table and inserts it into a SQL table, so that we can report on some key metrics. All was fine until the start of August when it started inserted dates in US not UK format! i.e. Data for August 10th was inserted as "2011-10-08 17:02:21.000" when it should have been "2011-08-10 17:02:21.000". The PC definitely has UK set as its region and the collation of the table is Latin1_ General_ CI_AS, which I believe is correct for UK. Can anyone think of where I shoudl be looking as I've run out of ideas? Thanks.
(comments are locked)
|
|
Have a look at SET DATEFORMAT Or use a string format which always works for dates in SQL Server - eg YYYYMMDD hh:mm:ss.nnn
(comments are locked)
|
|
you might investigate using a trigger to check the inserted value but that may cause more issues. Can you import it to a staging table somewhere and do a sanity check on the data? Or replace the script with a SSIS package to handle the date format for you?
(comments are locked)
|
|
Whatever your date settings in SQL Server, you can get any known format of date if it is consistent. If you are processing a data feed it is best to make it explicit, rather than to rely on the date format settings of your server (Oh boy, the errors that are caused when the server moves over the Atlantic) The simplest way to do this is if the day and month are reversed to what you expect (We brits like to go Day Month Year) This means that .... . .. and ... will give you the same DateTime In your case, you have a bug, frankly since there is no known date format (international standard time format) in SQL Server that goes yyyy-dd-mm. Instead, you have to resort to pesky string manipulation. but be there when they fix the bug!!
(comments are locked)
|


I think the problem was that the system started AFTER the 12th of July so that dates were converting OK, but once we got to 1st of August they were interpreted wrongly.
It's a 3rd party scripting product so is proving "fun" to fix - luckily my boss has moved it to the low priority pile.
Will post fix when I have one!
Have you looked at a trace to see what TSQL the app is generating?