如何在SQL和Oracle中获取当前时区 [英] How to Get current time zone in SQL and Oracle

查看:539
本文介绍了如何在SQL和Oracle中获取当前时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个C ++服务器应用程序,它在应用程序和数据库之间进行通信。我的服务器应用程序与oracle和SQL通信。现在我想获得我的oracle和SQL数据库的时区。我现在能够在SQL中获取当前时区我希望在oracle中获取当前时区。谁能帮助我找到oracle的时区。



提前致谢。

解决方案

您可以使用DBTIMEZONE或SESSIONTIMEZONE ...

http ://docs.oracle.com/cd/B19306_01/server.102/b14200/functions143.htm [ ^ ]

http://psoug.org/definition/DBTIMEZONE.htm [ ^ ]


请阅读我对Kornfeld Eliyahu Peter的解决方案1的评论。



我'我几乎可以肯定在Oracle服务器上获取时区名称是不可能的,因为它不受支持。

我相信你需要写自定义功能 [ ^ ]。基本思路是获取时间偏移并将其与时区列表进行比较,而不是返回正确的时区名称。



看看这里:

时区 [ ^ ]

获取时区名称 [ ^ ]



注意:我无权访问Oracle数据库/服务器,所以我错了。



BTW:它也可能有用:转换时区AT TIME ZONE条款 [ ^ ]

Hi All,
I have a server application in C++ which communicates between application and database. My server application communicates with both oracle and SQL. Now i want to get the time zone of my oracle and SQL database. I am able to get the current time zone in SQL now i want to get the current time zone in oracle. Can anyone please help me to find the time zone in oracle.

Thanks in advance.

解决方案

You can use DBTIMEZONE or SESSIONTIMEZONE for that...
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions143.htm[^]
http://psoug.org/definition/DBTIMEZONE.htm[^]


Please, read my comment to the solution 1 by Kornfeld Eliyahu Peter.

I'm almost sure it's impossible to get time zone name in Oracle server, because it's not supported.
I believe you need to write custom function[^]. The basic idea is to get time offset and compare it with the list of time zones, than to return proper time zone name.

Have a look here:
A Time Zones[^]
Obtaining Time Zone Names[^]

Note: i don't have access to Oracle database/server, so i can be wrong.

BTW: It might be useful too: Converting Time Zones With the AT TIME ZONE Clause[^]


这篇关于如何在SQL和Oracle中获取当前时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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