Is there a more concise way to extract standard time zone than this? [message #690324] |
Fri, 21 March 2025 09:37  |
 |
Darth Waiter
Messages: 87 Registered: October 2020
|
Member |
|
|
Here's what I've slapped together:
select TO_CHAR(EXTRACT(TIMEZONE_HOUR from from_tz(CAST (t.LAST_ANALYZED as timestamp), '-01:00')), 'FM00') || ':' || LPAD(CAST(EXTRACT(TIMEZONE_MINUTE from from_tz(CAST (t.LAST_ANALYZED as timestamp), '-01:00')) AS VARCHAR2(3)), 2, 0) as tz
from all_tables t
where rownum < 9
Don't mind the table or column - they are simply examples that are always available.
TZ
-01:00
-01:00
-01:00
-01:00
-01:00
[Updated on: Fri, 21 March 2025 09:37] Report message to a moderator
|
|
|
|
Re: Is there a more concise way to extract standard time zone than this? [message #690326 is a reply to message #690325] |
Fri, 21 March 2025 10:34   |
 |
Darth Waiter
Messages: 87 Registered: October 2020
|
Member |
|
|
Yes, this is perfect!
On a different topic, emails from the forum still contain invalid links:
[ <a href=3D"//www.orafaq.com/forum/?t=3Dpost&reply_to=3D690325">Reply<=
/a> ][ <a href=3D"//www.orafaq.com/forum/?t=3Dpost&reply_to=3D690325"=
e=3Dtrue">Quote</a> ][ <a href=3D"//www.orafaq.com/forum/?t=3Drview&goto=3D=
690325#msg_690325">View Topic/Message</a> ][ <a href=3D"//www.orafaq.com/=
forum/?t=3Drview&th=3D208739">Unsubscribe from this topic</a> ]
The 3D after `href=` and double quotes around the rest still mess them up. Colon is or in HTML, not 3D.
[Updated on: Fri, 21 March 2025 10:36] Report message to a moderator
|
|
|
|
Re: Is there a more concise way to extract standard time zone than this? [message #690329 is a reply to message #690326] |
Sat, 22 March 2025 08:29   |
Solomon Yakobson
Messages: 3305 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
You want to get table last analyzed date time zone offset, right? Then use at time zone and not just TZH:TZM Compare:
SQL> select last_analyzed,
2 to_char(cast(last_analyzed as timestamp with time zone),'tzh:tzm') wrong_offset,
3 to_char(cast(last_analyzed as timestamp with time zone) at time zone 'US/EASTERN','tzh:tzm') correct_offset
4 from dba_tables
5 where rownum <= 4
6 /
LAST_ANALYZED WRONG_OFFSET CORRECT_OFFSET
------------------- ------------ --------------
03/03/2025 22:01:41 -04:00 -05:00
03/16/2021 06:35:39 -04:00 -04:00
01/26/2025 06:01:52 -04:00 -05:00
03/16/2021 06:37:52 -04:00 -04:00
SQL>
SY.
|
|
|
|
|