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.
Author |
Topic |
slihp
Yak Posting Veteran
61 Posts |
Posted - 2014-05-01 : 11:58:58
|
In my previous job i started all my stored procs that passed in date variables with SET DATEFORMAT DMYas i was UK based it was just a bad habit i got into to ensure regional settings never interfered with my results.Im now in a new position where ill be writing stored procs that will have the potential to be run globally, so id like to write them in such as way as any dates passed i don't need to worry about the regional settings sql is on.im aware of a few ways to do this but would like to ask the question and get expert confirmations.Thanks |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2014-05-01 : 12:16:12
|
My suggestion would be to always use an ANSI or ISO date format for date strings (unambiguous):yyyy-mm-ddThh:mi:ss.mmm (no spaces) - ISO8601yyyy-mm-ddThh:mi:ss.mmmZ (no spaces) - ISO8601 with time zone Z.yymmdd OR yyyymmdd - ISO But, if you are writing sprocs, then you should, hopefully, be using the proper data types, so format doesn't really have an affect there. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|