Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Date Format Problem

Author  Topic 

chris_lunt
Starting Member

25 Posts

Posted - 2011-09-06 : 04:57:21
Hello Folks

When I run SELECT CAST(CONVERT(VARCHAR(11), GETDATE(), 103) AS DATETIME) I get 2011-09-06 00:00:00.000 returned, a colleague gets 2011-06-09 00:00:00.000

This is causing a headache because when we look at information retutrned between 2 dates I'm looking between one day and the next however a colleagues machine thinks he's looking between one month and the next and returning loadfs of rows.

Please cna yu tell me what setting we alter (& where it is) so that his machine returns 2011-09-06 00:00:00.000

Many thanks

Chris

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-06 : 05:29:59
why should you convert it? provided you always pass date values in unambiguos format yyyyddmm there's no question of any such problems

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

chris_lunt
Starting Member

25 Posts

Posted - 2011-09-06 : 05:33:17
Cheers for the response, perhaps you're right but as we hvae procedures that already convert the date it would be good to get the colleagues machine reading them in the same format.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-09-06 : 09:48:18
Viskh's solution is the right way.

The reason you're seeing this is because you and your colleague have different locale settings. Which is exactly why what Visakh suggested is the right way -- it isn't affected by local settings.
Go to Top of Page
   

- Advertisement -