数据库的时区设置 [英] Timezone setting for database

查看:311
本文介绍了数据库的时区设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



是否可以为SQL Server 2008数据库分配时区?
我们为客户提供不同的数据库.
每个客户都在不同的时区.我们希望"GetDate()"函数根据时区设置返回时间.


Hi,

Is it possible to assign a Time Zone to a SQL Server 2008 database?
We have different databases for our clients.
Each of clients are in different Time zones. we want the "GetDate()" function to return time according to the timezone setting.


Thanks.

推荐答案

一个词:不要.

仅当您需要向用户显示时间和/或日期时,时区才重要.在内部,您应始终将所有时间存储和处理为UTC值.这样,当用户希望显示记录时,可以在显示时应用该用户的时区偏移量,而与数据最初来自哪个时区无关.
One word: Don''t.

TimeZones only matter when you need to display a time and/or date to a user. Internally you should store and manipulate all times as UTC values. That way when a user wishest to display a record you can apply that user''s timezone offset at the point of display, and it does not matter which timezone the data originally came from.


这篇关于数据库的时区设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆