I often wonder about how to proceed with consultations involving date fields. Well, in general we can say that doing the query using the standard 'yyyy-mm-dd' or 'yyyymmdd' (where [y] ear, [m] onth, [d] y, respectively) will not have problems.
Code, description, DataCadastro
FROM Customers
WHERE
DataCadastro = '2007-10-07 '
Well, not quite, so that the syntax above works, the server (and logged in user) must be using the English language. Now, if the server has been installed in Portuguese language, or even an application that worked before because I was on a server whose first language was English and had been restored to a server whose first language is Portuguese. For these cases we would need an instruction to change the language, the following script would do the job.
SELECT @ @ language, @ @ langid - SETTING THE DEFAULT LANGUAGE FOR THE SERVER
EXEC sp_configure 'default language', 0
- SET LANGUAGE FOR EACH SERVER LOGIN
EXEC sp_defaultlanguage 'sa', 'us_english'
- EXEC sp_defaultlanguage 'UserName', 'us_english'
- EXEC sp_defaultlanguage 'Machine \ User', 'us_english'
- COMMAND CHANGES MADE TO RESET
RECONFIGURE
- After that will be MUST GIVE THE START and STOP SQL SERVER
to the next.
