Question

SYSDATE different from AIX DATE command

Asked by: jrollins138

I'm having a problem with SYSDATE not returning the correct value. I'm running Oracle 9i on an IBM RS/6000 running AIX 5.2. I'm pretty sure the problem relates to how AIX/Oracle are handling the switch to daylight savings time (I'm in the US).

The command I'm running is "SELECT TO_CHAR(SYSDATE, 'mm/dd/yyyy hh:mi:ss') from dual;"

When I run this command using SQL*Plus on the RS/6000, I get "10/29/2009 09:28:59"
When I run "date" from the AIX command prompt, I get "Thu Oct 29 09:28:59 CDT 2009"
When I run this command using SQL*Plus on a Windows 98 PC, I get "10/29/2009 08:28:59"

The correct time is 09:28:59.

The timezone variable on the RS/6000 is "CST6CDT,M3.2.0,M11.1.0".

This problem surfaced about three days ago.

Can you tell me why the PC is returning a time 1 hour earlier than it should be?

Thanks,

Im

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-10-29 at 07:35:50ID24854720
Tags

AIX SYSDATE TIMEZONE TZ

Topic

Oracle Database

Participating Experts
3
Points
500
Comments
39

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. ORACLE SYSDATE
    The date and time returned by the function SYSDATE varies when accessing the same database depending on the value of the TWO_TASK environment variable. Case 1) ------- TWO_TASK = < connect string > Observation: SYSDATE returns a date and time different from the dat...
  2. sysdate problem
    Making a question to a table where i want to add sysdate but it dont get the valu automatic, as seen in text below Part of script column to_char(sysdate,'_yyyymmdd_hh24miss') on new_value my_sysdate spool d:\xxx\xxx\xxxxx&my_sysdate select 'begin' from dual; answer whe...
  3. Problem with sysdate
    ID NAME BDATE -- -------------------- --------- 1 Diapk 13-SEP-02 2 Deba 12-SEP-02 3 BIDYIT 14-SEP-02 4 KAUSIK 10-SEP-02 5 PRANAY 07-SEP-02 6 KAUSIK 05-SEP-02 7 AMIT ...
  4. SYSDATE
    I have the join, below, which is oriented toward oracle. How do I select the "sysdate" within db2? How do I rewrite my join? FSCMDMO.PS_DEPT_TBL.EFFDT=(SELECT MAX(DEP1.EFFDT) FROM FSCMDMO.PS_DEPT_TBL DEP1 WHERE DEP1.DEPTID=FSCMDMO.PS_DEPT_TBL.DEPTID AND DEP1.SE...
  5. sysdate in GMT
    Hi I have the following statement insert into tabA(sysdate,"value1"); Currently it inserts the date in the server timezone. However i would like to store all dates in GMT In DB2 there is a way to subtract the currenttimezone eg: INSERT INTO T1 values (current ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: sdstuberPosted on 2009-10-29 at 07:42:41ID: 25694186

are your oracle timezone files up to date?

Last Sunday was the old DST switch which would correspond with when you saw your error occurring


select * from v$timezone_file

 

by: mrjoltcolaPosted on 2009-10-29 at 07:44:43ID: 25694210

What is the timezone on the PC?

Oracle client will affect the timezone at the session level, which will convert times coming from the database.

See if this changes things, from client PC:

SQL> alter session set time_zone = DBTIMEZONE;

SQL> select sysdate from dual;

 

by: jrollins138Posted on 2009-10-29 at 08:14:52ID: 25694599

ststuber:
  I don't have a "v$timezone_file". I do have a "v$timezone_names" that has columns TZNAME and TZABBREV. There is a record for my timezone: CST.

mrjoltcola:
I ran the commands from my PC and got the same result. The time is still an hour off.

 

by: sdstuberPosted on 2009-10-29 at 08:20:51ID: 25694671

oops sorry, 9i didn't have that

you'll have to use

$ORACLE_HOME/rdbms/admin/utltzver.sql

if you don't have that script then you can download it from metalink

see metalink doc id 412160.1 for the link and description

 

by: johnsonePosted on 2009-10-29 at 08:28:15ID: 25694765

While I completely agree that this is probably an issue with the timezone patch not being applied, I want to bring up one other way I know this can happen.

If the TZ environment variable on the AIX box is not set correctly when the listener is started, you can affect how the clients will see times.  A quick way to rule this out is to ensure the TZ variable is set correctly, then issue "lsnrctl stop" and "lsnrctl start".

 

by: jrollins138Posted on 2009-10-29 at 08:41:33ID: 25694920

sdstuber:
  Sorry. I don't have the utility and I don't have an account on metalink.

johnsone:
  Is the timezone patch you referred to an AIX thing or an Oracle thing? I'm thinking the AIX TZ variable is set properly because the AIX "date" command returns the proper value and SQL*PLUS returns the correct date when run on the RS/6000. It's only when I run SQL*PLUS from a Windows PC that I have a problem.

 

by: sdstuberPosted on 2009-10-29 at 08:45:36ID: 25694959

if the sysdate changes based on where you query it from, then it's definitely a client issue as mentioned by mrjoltcola

 

by: mrjoltcolaPosted on 2009-10-29 at 08:50:13ID: 25695007

@sdstuber: I was just about to post before you said this. SYSDATE, by the docs, is based on the time on the server. So it should not change with client settings.

 

by: johnsonePosted on 2009-10-29 at 08:55:19ID: 25695061

I was referring to the Oracle time zone patch referenced by sdstuber.

 

by: jrollins138Posted on 2009-10-29 at 09:08:58ID: 25695188

I've been playing with the timezone setting on my Windows PC and using SQL*PLUS to query SYSDATE. No matter how I change the PC's setting, it always returns the same (wrong) time.

Let's try this problem from another tack: is there a way to get the server date/time regardless of how the PC is configured?

 

by: sdstuberPosted on 2009-10-29 at 09:10:27ID: 25695209

mrjoltcola,
yes, you're correct  the client (session) settings should not make a difference in SYSDATE (current_date, yes, but not sysdate)

however, the dates are clearly dependent on where the query is run.
hmmm

maybe it's the wrong "where"

jrollins138,
are you  sure you are connecting to the same database?

 

by: mrjoltcolaPosted on 2009-10-29 at 09:12:49ID: 25695236

>>is there a way to get the server date/time regardless of how the PC is configured?

Yes, it has traditionally been SYSDATE. :(

Can you give us some details on version on the PC?

 

by: mrjoltcolaPosted on 2009-10-29 at 09:18:06ID: 25695285

I cannot replicate this problem here. Not that that makes anyone feel any better, for as always, I perform sanity checks even on things I've used for years.

I'm thinking bug in the client. (Either that or I am about to learn something new about Oracle...)

Can we see your environment settings on the client?

 

by: jrollins138Posted on 2009-10-29 at 09:23:27ID: 25695332

sdstuber
  yup, verified database connections. They're pointing to the same DB.

mrjoltcola
  the PC is just a plain-vanilla XP box (SP 3).

I've got another AIX box with Oracle on it. I can't restart the listener on my main system during business hours but I can on this other guy. I'll see if altering the AIX TZ environment variable has an impact.

 

by: sdstuberPosted on 2009-10-29 at 09:26:33ID: 25695361

how about this..

are you connecting with /

or with @ ?

for example

sqlplus /
vs
sqlplus username/password@dbname

when I used / on the server, my current TZ setting overrode the db's timezone and sysdate came back different

when I connected through sql*net, the db's timezone prevailed

 

by: jrollins138Posted on 2009-10-29 at 09:36:55ID: 25695480

sdstuber:
  Interesting question. On the PC, I'm just clicking the SQL*PLUS icon which runs with no command line arguments. It pops a dialog that prompts for login, password and database. It then runs a GUI version of SQL*PLUS

When I ran it from the PC's command line:

sqlplus user/pass@db

It brought up a command line version. The results were the same, however (time is an hour off).

Running "sqlplus /" just produced an error about a TNS protocol adapter error.

Disclaimer: I did some more checking. What I've been referring to as "SQL*PLUS" was, in fact, SQLPlus Worksheet, the graphical version of SQL*Plus. The results have been identical. I apologize for any inconvenience.

 

by: mrjoltcolaPosted on 2009-10-29 at 09:40:58ID: 25695531

That would point back to the listener, then, as johnsone speculated.

The listener spawns a server process, so whatever TZ it was started with is what you get, through the listener.

 

by: sdstuberPosted on 2009-10-29 at 09:44:40ID: 25695584

actually no,  in my test I had a session pre-TZ change open, and post-TZ change with listener bounce and they both returned the same sysdate

The only one time TZ mattered to remote clients is the TZ at the time the DB is started

 

by: mrjoltcolaPosted on 2009-10-29 at 09:53:25ID: 25695666

>>The only one time TZ mattered to remote clients is the TZ at the time the DB is started

Yes, I just finished the same test case and listener TZ did not affect SYSDATE.

 

by: mrjoltcolaPosted on 2009-10-29 at 09:56:34ID: 25695711

Does everyone have Metalink. Read article 399448.1

 

by: jrollins138Posted on 2009-10-29 at 10:21:32ID: 25695952

mrjoltcola:
  Sorry. I don't have it. My company does not have a support relationship with Oracle. (Very long and uninteresting story.)

I've been doing some testing on my second AIX box and I'm convinced the issue has to do with the TZ environment variable. Here's what I think is going on::

- AIX knows how to interpret the additional values in my TZ string (CST6CDT,M3.2.0,M11.1.0). Oracle does not.

- Everybody is looking at what the TZ variable is set to when the system boots up. I tried setting TZ from the shell and then stopping and starting the listener and nothing changed. When I set TZ to "CST6CDT" in /etc/environment and then rebooted the AIX box, everything started behaving predictably.

- I'm pretty sure both IBM and Oracle have fixed everything related to this problem and I'm being plagued by my Luddite tendencies to not stay current.

I'm splitting the points between both respondents because I genuinely appreciate you both hanging in there and helping me work through this.

Thank you very much.

 

by: jrollins138Posted on 2009-10-29 at 10:27:57ID: 25696032

Drat. I wanted to split the points evenly between the three participants. Can someone help me change this?

 

by: mrjoltcolaPosted on 2009-10-29 at 10:29:39ID: 25696050

There is a difference between static listener config and dynamic, and between using SERVICE_NAME vs SID.

Oracle docs say for static configs (using SID) that the environment vars are inherited from the user who started the listener.

I have tested, and there is some difference, but I haven't a clear test case yet, other than to point you to that Metalink doc, and to look at how your listener is configured, and how yoru tnsnames.ora is setup (whether to use SID or SERVICE_NAME).

 

by: sdstuberPosted on 2009-10-29 at 10:34:41ID: 25696106

"Can someone help me change this?"

I have clicked the "Request Attention" link for you to have a moderator reopen the question and let you split the points however you want.

 

by: jrollins138Posted on 2009-10-29 at 10:39:29ID: 25696152

sdstuber:
  Thanks for flagging the moderator for me. I'll reassign points.

mrjoltcola:
  Interesting. My tnsnames.ora is using the "SID = ???" method, rather than SERVICE_NAME. I never knew what the difference was.

 

by: mrjoltcolaPosted on 2009-10-29 at 10:49:50ID: 25696255

I'm less concerned about you closing the question than finding the root of this problem. I will return to this question, sorry I cannot finish my test case right now, but I will say I reproduced some odd behaviour switching between static and dynamic listener config and SID vs SERVICE_NAME. I'd rather not speculate, as I have to run to a meeting, but I'll followup.

 

by: jrollins138Posted on 2009-10-30 at 06:54:50ID: 25702936

I did some playing around with both AIX systems last night. In both cases, simply rebooting the systems had no affect on the symptoms. The one factor that seems to affect everything is the TZ environment variable.

This value is defined in /etc/environment. I set it to "TZ=CST6CDT,M3.2.0,M11.1.0". The "M3,2.0" tells AIX that DST goes into effect on March 2. The "M11.1.0" tells AIX when DST ends November 1. My theory is that AIX knows how to handle all of this but the Oracle client doesn't. (Special comment: I'm not current on either AIX or Oracle. It's very likely that IBM and Oracle have patched both of these situations.)

The symptoms are that the date returned by AIX is correct, the SYSDATE returned by SQL running on the server is correct, but the SYSDATE returned by SQL running on a client PC is one hour off. If I change the AIX date, the two SYSDATE values change correspondingly.

When I set the TZ variable to "TZ=CST6CDT" and reboot, all three dates are the same.

The net of all this is that I either need to update my system/db software or manage the daylight savings time thing manually.

 

by: mrjoltcolaPosted on 2009-10-30 at 07:08:18ID: 25703063

In all cases, SYSDATE comes from the DB server and is affected by the Timezone of the server process.

In the case of dynamic server registration (ie. no static listener entry) your environment variables will be registered by PMON when the service registers with the listener.

It is possible to configure listeners to have different timezones, if you use static entries by adding the TZ to the listener.ora explicitly, using the listener.ora ENVS='' param. Check yours to see if you have one. If so, remove it.

If not, and the symptom persists after after a reboot (where EVERYTHING should have the same TZ) then I would say either:
1) Your auto-start is misconfigured and the TZ var is not set right by the dbstart script.
2) There is a bug somewhere between how the listener is handling DST.

It would help to see your listener.ora file and your .profile or /etc/profile (or however else you are configuring environment).

 

by: sdstuberPosted on 2009-10-30 at 07:33:08ID: 25703316

since you're manually manipulating the DST conversions,  the most likely case I can think of is your database was started with the old (pre-Energy Policy Act of 2005) DST rules which is why your times became off by an hour when the last transition occurred.


or,  are you saying if you use "TZ=CST6CDT,M3.2.0,M11.1.0" and reboot  then your dates and times still aren't in synch?

 

by: sdstuberPosted on 2009-10-30 at 07:37:58ID: 25703374

If you are using AIX 5 and get your support up to date you can get your DST rules applied automatically

If not, you will have to maintain your TZ variables manually with the transition dates and reboot every year before the spring transition to set the correct dates

 

by: jrollins138Posted on 2009-10-30 at 07:43:29ID: 25703415

sdstuber:

What appears to be happening is that AIX knows how to handle the extra stuff on the end of the TZ string but the Oracle PC client doesn't. It may be related to how the client is connecting to the server (SID vs SERVICE_NAME) but the result is that I can't sync up the dates.

I'm reconciled to managing the server time manually without the special AIX functionality. Ah well.

 

by: mrjoltcolaPosted on 2009-10-30 at 07:47:33ID: 25703459

>>What appears to be happening is that AIX knows how to handle the extra stuff on the end of the TZ string but the Oracle PC client doesn't.

I don't think the PC / Client has anything to do with it. Originally we suggested because it seemed the obvious differentiating factor, but after consideration, the real differentiating factor seems to be the LISTENER / remote connections.

You could verify this by connecting from another Oracle client from, say, an AIX account with no TZ variable.

 

by: sdstuberPosted on 2009-10-30 at 07:49:26ID: 25703480

it's the reboot, or more precisely, the restart of the database AFTER changing the TZ that matters
also possibly the restart of the listener if you have TZ settings there.

So, just to be precise.

After your used "TZ=CST6CDT,M3.2.0,M11.1.0" ,  did you reboot?

If so,  did anything alter the TZ  before your database and listeners started?

 

by: sdstuberPosted on 2009-10-30 at 08:05:06ID: 25703672

to be sure of the TZ for your database

please post the results of

ps eww 123456  

where 123456 is the process number of your database pmon process

if you want show all of the pmon processes

ps -ef |grep pmon|awk '{print $2}' | ps eww

 

by: jrollins138Posted on 2009-10-30 at 09:58:22ID: 25704851

I've rebooted after changing the TZ setting in /etc/environment so that I could be absolutely certain what TZ was in effect.

I'll have to postpone this discussion for the rest of the day. I just lost a harddrive in my production box and I'm recovering from that. I'll check back in tomorrow.

I'll run the ps eww command then.

Thanks again for the help.

 

by: jrollins138Posted on 2009-11-02 at 12:22:49ID: 31647523

Thanks again everyone. I appreciate the help.

 

by: sdstuberPosted on 2009-11-02 at 12:43:09ID: 25723500

glad we could help,  did something in the ps eww help?

is the problem truly resolved? if so, what was the final outcome?

 

by: jrollins138Posted on 2009-11-02 at 12:56:19ID: 25723616

As of Sunday, the opportunity to really test has expired. I think there were too many variables to nail this down completely. These include:

- An old, unpatched version of AIX (5.1 and 5.2) on my two machines.
- An old, unpatched version of Oracle (9.1) on both machines.
- Uncertainty as to where the timezone reconciliation was being done.
- Uncertainty about Oracle's ability to handle the extra text (",M3.2.0,M11.1.0") on the end of the TZ environment variable.

There were just too many permutations to test to be sure I had the right circumstances.

What I ended up doing was stripping the TZ variable back to "CST6CDT" and manually adjusting the time on the server if it was wrong.

I'm in the process of upgrading all the software on these two systems. I may be back in this forum again come March.

I appreciate the insights you folks had to offer and am quite happy with the results.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...