![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Is there a feature I can use in SQL server 2005 which can apply the offset during insert update and select based on the database user log-in? (i.e. so that the dates are stored in GMT but as far as that database user is concerned they will be in USA(EST)?) |
#3
| |||
| |||
|
|
I have an database with many datetime columns in many different entities. My application language has theoretically the facility to adjust the times based on the variation between the client locale and the server locale, but it's really buggy. Is there a feature I can use in SQL server 2005 which can apply the offset during insert update and select based on the database user log-in? (i.e. so that the dates are stored in GMT but as far as that database user is concerned they will be in USA(EST)?) I'm hoping that the application language will fix the bugs, allowing me to do this in the application, but until then, any ideas? |
#4
| |||
| |||
|
|
Iain Sharp (iains (AT) pciltd (DOT) co.uk) writes: I have an database with many datetime columns in many different entities. My application language has theoretically the facility to adjust the times based on the variation between the client locale and the server locale, but it's really buggy. Is there a feature I can use in SQL server 2005 which can apply the offset during insert update and select based on the database user log-in? (i.e. so that the dates are stored in GMT but as far as that database user is concerned they will be in USA(EST)?) I'm hoping that the application language will fix the bugs, allowing me to do this in the application, but until then, any ideas? SQL Server has no information about the client's timezone. So if the client is in New York, and sends in 2010-05-29 13:31 and this is -04:00, there is no way you can no this in SQL Server with less than passing the time zone from the client. If you have the offset, dateadd will help you. But that is also all you have. In SQL 2008 there are some new datetime data types, including datetimeoffset, so that you can store a time-zone value with the datetime value. |
#5
| |||
| |||
|
|
Yeah, that's mostly what I was afraid of. I was hoping that there was a timezone offset as an attribute of a database user or something which would do this for me universally. |
#6
| |||
| |||
|
|
Yeah, that's mostly what I was afraid of. I was hoping that there was a timezone offset as an attribute of a database user or something which would do this for me universally. If your users do not travel much and you know where they work you could store the UTC offset in the user profile and use DATEDIFF to compute the UTC. Downside is that you will have to alter the user settings based on local summer / winter time rules. brgds Philipp Post |
![]() |
| Thread Tools | |
| Display Modes | |
| |