在 SQL Server 2000 中动态将 GMT 日期转换为 BST
我有一个表,其中包含一个月中每 30 分钟的值,例如
20/03/2010 00:00 12
20/03/2010 00:30 14
等
所有这些数据都存储在 GMT 中
我需要在此表上对 bst/时钟时间中的数据进行选择
,例如
select *
from tbl
where dt between '01 April 2010' and '30 April 2010 23:30'
在 BST 中时上面的日期范围是需要转换的日期
我还需要一种将转换时间以及三月底和十月考虑在内的方法
不幸的是我无法升级 SQL Server
有什么方法可以在 SQL for SQL Server 2000 中执行此操作?
我可以做类似的功能吗?
select *
from tbl
where fnConvertToClockTime(dt) between '01 April 2010' and '30 April 2010 23:30'
当处于 GMT 时,该函数将从表
Cheers
Rupert中返回准确的日期
I have a table which contains a value for every 30 minutes in a month, e.g.
20/03/2010 00:00 12
20/03/2010 00:30 14
etc
All of this data is stored in GMT
I need to do a select on this table for the data in bst/clock time
for example
select *
from tbl
where dt between '01 April 2010' and '30 April 2010 23:30'
when in BST as the date range above is the dates need to be converted
I also need a way of taking the changeover hour and the end of March and October into account
Unfortunatly I cannot upgrade SQL server
Is there any way that I can do this in SQL for SQL Server 2000?
something like a function I could do?
select *
from tbl
where fnConvertToClockTime(dt) between '01 April 2010' and '30 April 2010 23:30'
When in GMT the function would return the exact date from the table
Cheers
Rupert
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有同样的问题,正在研究日历表在此类转换中的使用。将所有日期存储在 UTC 时间中,然后根据需要进行转换,我可能会为不同时区创建视图以避免参数传递,但我想存储过程也可以工作。
我在这里找到了一些有用的信息:how-do-i-convert-local-time-to-utc-gmt-time
以及有关日历表的相关文章:为什么-我应该考虑使用辅助日历表
I have the same problem and am investigating the use of Calendar tables for such convserions. Store all dates in UTC time then convert as necessary, I'm probably going to create VIEWS for the different time zones to avoid parameter passing but I guess a stored procedure would also work.
I found some useful information here: how-do-i-convert-local-time-to-utc-gmt-time
And an associated article on Calendar tables here: why-should-i-consider-using-an-auxiliary-calendar-table