Oracle timestamp with timezone
Does CR support column of type "timestamp with timezone" column. I am getting error message "Failed to retrive data from database. Details:Not implemented". Thanks
Since this is the Crystal Reports Java forum, you need to specify the explicit Java java.sql Type that the Oracle JDBC driver exposes the database type as.
I'm not familiar with that data type, so don't know if it's mapped to the Timestamp type or not.
Note that CR4E 2.0 supports up to JDBC 4.0 types.
Sincerely,
Ted Ueda
Similar Messages
-
Oracle ODBC driver and TIMESTAMP with timezone
Does anyone know if it is possible to return data from a "TIMESTAMP WITH TIMEZONE" column using the Oracle ODBC driver and an ADO Recordset?
I am using the Oracle driver version 10.2.0.2 and TIMESTAMP fields work fine.
I can call Recordset->Open() with a query like "SELECT * FROM TABLE" when the table contains a column of type timestamp with timezone but when I execute a statement to see if there are results as in
if (!(srcRecsetPtr->BOF && srcRecsetPtr->EndOfFile))
my application throws an unhandled exception and exits. The exception is not a COM exception and I'm not sure how to get back additional information if that's possible.
The only information I've been able to find in searching TechNet and MetaLink is that a workaround is to wrap the columns in a TO_CHAR or TO_DATE conversion first but that's not a good solution for my problem since I am executing user specified SQL which may join multiple tables.
I've found one other note that says the documentation should be corrected and that these fields are NOT supported period (Bug #4011640).
I've experimented with the Bind Timestamp as Date option in the ODBC connection and with various ALTER SESSION settings to attempt to change the NLS_TIMESTAMP_TZ_FORMAT but I have been unable to get past the problem.
Any ideas are greatly appreciated.
Thanks,
TroyHi Justin
Thanks for your help.
I tried what you mentioned and I could connect myself via SQL*Plus without passing a password and a login, Extern authentification seems to work and my user seems to be right configurated.
But he problem goes on via ODBC. When I test connection in the ODBC Data Source Administrator of Windows XP, test fails and seems to forbid connection without userID and password. When I try to connect via ODBC in my program the same problem appears : "Unable to connect SQLSTATE=28000 [Oracle][ODBC][ORA]Ora-01017: Invalid username/password;logon denied" I could not connect in this way.. What's wrong ? -
Converting timestamp with timezone to milisecs
Hi guys,
How to converting timestamp with timezone to milisecs?
I'm using oracle 10g.SeánMacGC wrote:
Hello, do you mean:
SQL> select to_char(systimestamp, 'SSSSS') from dual;
TO_CH
58435
'SSSSS' Format Model returns 'Seconds past midnight' not milliseconds. I wonder if OP meant Fractional Seconds?
SQL> SELECT TO_TIMESTAMP_TZ('1999-12-01 11:00:00.00532 -8:00',
2 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM') col_1 FROM DUAL
3 /
COL_1
01-DEC-99 11.00.00.005320000 AM -08:00
SQL> SELECT TO_CHAR(col_1, 'FF') fractional_sec FROM
2 (SELECT TO_TIMESTAMP_TZ('1999-12-01 11:00:00.00532 -8:00',
3 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM') col_1 FROM DUAL)
4 /
FRACTIONA
005320000
SQL>Regards,
Jo
Edited by: Joice John : Added Code Tags -
Why have I lost the info of timezone (Timestamps with Timezone )
I have been trying to get timestamps with timezones working in my Java application, but I don't seem to get the data I expect back from the JDBC driver
my field type is Timestamps with Timezone ,in the database,I saw the info of (12-DEC-06 01.12.12.123000 PM -06:00),but I don't know How to get it from Java
I've use the Timestamp aa =rs.getTimestamp("FIELDVALUE");but the timezone is lost, what can I do?
thanksTimestamps are always GMT based (or could be thought of as timezone neutral) so what you should get back is a timestamp representing a GMT equivalent of the time you see that has a 6 hour offset from GMT. In other words, if the time were 1 PM Central Standard you would get a GMT time of 7 PM.
You should then be able to display that time in any time zone you wish using SimpleDateFormat and specifying the time zone you want to display it in. So if you then display it with Central Standard, the 7 PM GMT would then display as 1 PM again. In other words, 7 PM GMT and 1 PM Central Standard are the same timestamp
If you just display the timestamp using a toString(), you will get the time in the default time zone of the JVM..
Whether the driver actually does this correctly with the Oracle database I can't say. I've made several posts in a variety of places complaining that the driver does not work correctly with timestamps but my experience is limited to regular timestamp fields, not the new Oracle type of timestamp with timezone.
Based on my experience, what you are more likely getting back in the 1 PM- 7 PM example is 7 PM in the default timezone of the JVM.
You should look at the getTimestamp with Calendar options to see if they work better for you.
The main thing to keep in mind is that timestamps are really timezone neutral. -
Compare 2 'timestamp with timezone' columns
Hi All,
I'm trying to compare 2 'timestamp with timezone' columns,
comparision works fine as long as there is difference of at least seconds between them.
But when the difference between them is in milliseconds, comparison is failing.
I'm using oracle 10g.
Pls advice.Works just fine:
SQL> DECLARE
2 t1 TIMESTAMP WITH TIME ZONE := TIMESTAMP '2008-01-10 10:25:17.123456 US/EASTERN';
3 t2 TIMESTAMP WITH TIME ZONE := TIMESTAMP '2008-01-10 10:25:17.323456 US/EASTERN';
4 BEGIN
5 IF t1 <= t2
6 THEN
7 DBMS_OUTPUT.PUT_LINE('t1 <= t2');
8 END IF;
9 END;
10 /
t1 <= t2
PL/SQL procedure successfully completed.
SQL> DECLARE
2 t1 TIMESTAMP WITH TIME ZONE := TIMESTAMP '2008-01-10 10:25:16.123456 US/EASTERN';
3 t2 TIMESTAMP WITH TIME ZONE := TIMESTAMP '2008-01-10 10:25:17.323456 US/EASTERN';
4 BEGIN
5 IF t1 <= t2
6 THEN
7 DBMS_OUTPUT.PUT_LINE('t1 <= t2');
8 END IF;
9 END;
10 /
t1 <= t2
PL/SQL procedure successfully completed.
SQL> Based on your:
But when the difference between them is in milliseconds, comparison is failing. Most likely your code does implicit/explicit timestamp conversion to date. Post your code.
SY. -
Regarding timestamp with timezone
Hi,
I have the following timestamp with timezone issue.
From java program I am passing the datetime with timezone value to database (INTERVALTIME (column name)).
PrepareStatemenet statement;
java.util.Date dt = ISODateUtil.parse("2006-06-21T18:00:00+00:00");
SimpleTimeZone zone = new SimpleTimeZone(0,"IST");
Calendar cal = converting the dt to calendar;
cal.setTimeZone(zone);
statement.setTimestamp(col, new Timestamp(cal.getTimeInMillis()),cal);
In database INTERVALTIME (column name) coulmn type is TiMESTAMP WITH TIMEZONE.Database is in PDT (GMT-8) timezone.
Now the problem is :
Even if i send the datetime of IST timezone, it is displaying in PDT (GMT-8) timezone.
How can i resolve this issue?Reo wrote:
The query you provided doesn't run. If I want to convert to a different timezone, I need the from_tz.Is column update_time a TIMESTAMP WITH TIME ZONE? If so, then no casting is needed:
SQL> create table test(id number,update_time timestamp with time zone)
2 /
Table created.
SQL> insert into test values(1,systimestamp)
2 /
1 row created.
SQL> insert into test values(2,systimestamp at time zone 'UTC')
2 /
1 row created.
SQL> select id,
2 update_time,
3 update_time at time zone 'US/Pacific'
4 from test
5 /
ID
UPDATE_TIME
UPDATE_TIMEATTIMEZONE'US/PACIFIC'
1
18-NOV-09 04.23.03.241000 PM -05:00
18-NOV-09 01.23.03.241000 PM US/PACIFIC
2
18-NOV-09 09.23.29.346000 PM UTC
18-NOV-09 01.23.29.346000 PM US/PACIFIC
ID
UPDATE_TIME
UPDATE_TIMEATTIMEZONE'US/PACIFIC'
SQL> SY. -
Unique or primary key on timestamp with timezone
Hi,
I have been experimenting with a date column in a primary key, or actually I tried using a timestamp with time zone in a primary key.
While researching whether there was a way to avoid ORA-02329, I found the following:
K15> create table dumdum
2 (datum date not null
3 ,naamp varchar2( 30 ) not null);
Table created.
K15>
K15> alter table dumdum
2 add constraint d_pk
3 primary key
4 (datum, naamp)
5 using index;
Table altered.
K15>
K15> select ind.index_type
2 from user_indexes ind
3 where ind.index_name = 'D_PK';
INDEX_TYPE
NORMAL
1 row selected.
K15>
K15> insert into dumdum
2 (datum
3 ,naamp )
4 select sysdate - (level/1440)
5 , 'nomen nescio'
6 from dual
7 connect by level < 1000
8 ;
999 rows created.
K15>
K15> analyze index d_pk validate structure;
Index analyzed.
K15> analyze table dumdum compute statistics;
Table analyzed.
K15>
K15> select naamp
2 from dumdum
3 where datum > to_date('16-06-2011 15.46.16', 'dd-mm-yyyy hh24.mi.ss' )
4
K15> For the last select statement I get the following "explain plan":
SELECT STATEMENT CHOOSE
Cost: 2 Bytes: 247 Cardinality: 13
1 INDEX RANGE SCAN UNIQUE D_PK
Cost: 3 Bytes: 247 Cardinality: 13 This behavior lived up to my expectations.
Then, I tried this:
K15> create table dumdum
2 (datum date not null
3 ,naamp varchar2( 30 ) not null);
Table created.
K15>
K15> alter table dumdum
2 add constraint d_pk
3 primary key
4 (datum, naamp)
5 using index;
Table altered.
K15>
K15> alter table dumdum
2 modify datum timestamp(6) with time zone;
Table altered.
K15>
K15> select ind.index_type
2 from user_indexes ind
3 where ind.index_name = 'D_PK';
INDEX_TYPE
NORMAL
1 row selected.
K15>
K15> insert into dumdum
2 (datum
3 ,naamp )
4 select sysdate - (level/1440)
5 , 'nomen nescio'
6 from dual
7 connect by level < 1000
8 ;
999 rows created.
K15>
K15> analyze index d_pk validate structure;
Index analyzed.
K15> analyze table dumdum compute statistics;
Table analyzed.
K15>
K15> select naamp
2 from dumdum
3 where datum > to_date('16-06-2011 15.46.16', 'dd-mm-yyyy hh24.mi.ss' )
4
K15> So, at first glance, the alter table statement to change the datatype from DATE to TIMESTAMP seems like a way of fooling Oracle. But the explain plan reveals a different story:
SELECT STATEMENT CHOOSE
Cost: 4 Bytes: 1,25 Cardinality: 50
1 TABLE ACCESS FULL DUMDUM
Cost: 4 Bytes: 1,25 Cardinality: 50 I was only fooling myself. :-0
But I wasn't done with my research:
K15> create table dumdum
2 (datum timestamp(6) with time zone not null
3 ,naamp varchar2( 30 ) not null);
Table created.
K15>
K15> create unique index d_ind
2 on dumdum
3 (datum, naamp);
Index created.
K15>
K15>
K15> select ind.index_type
2 from user_indexes ind
3 where ind.index_name = 'D_IND';
INDEX_TYPE
FUNCTION-BASED NORMAL
1 row selected.
K15>
K15> insert into dumdum
2 (datum
3 ,naamp )
4 select systimestamp - (level/1440)
5 , 'nomen nescio'
6 from dual
7 connect by level < 1000
8 ;
999 rows created.
K15>
K15> analyze index d_ind validate structure;
Index analyzed.
K15> analyze table dumdum compute statistics;
Table analyzed.
K15>
K15> select naamp
2 from dumdum
3 where datum > to_date('16-06-2011 15.56.16', 'dd-mm-yyyy hh24.mi.ss' )
4
K15>Now, my explain plan looks fine:
SELECT STATEMENT CHOOSE
Cost: 2 Bytes: 1,25 Cardinality: 50
1 INDEX RANGE SCAN UNIQUE D_IND
Cost: 3 Bytes: 1,25 Cardinality: 50 Why is Oracle so adamant about not allowing a timestamp with time zone in a unique key? And, given their position on the matter, where does their tolerance for a unique index come from?
By the way, if I had a say in it, I would not allow anything that even remotely looks like a date to be part of a primary key, but that's another discussion.
Thanks,
Remco
P.S. All this is on Oracle9i Enterprise Edition Release 9.2.0.8.0. Is it different on 10g or 11g?See if this helps. You can create primary key for TIMESTAMP WITH LOCAL TIME ZONE datatype.
SQL>CREATE TABLE Mytimezone(Localtimezone TIMESTAMP WITH LOCAL TIME ZONE primary key, Location varchar2(20) );
Table created.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/ch4datetime.htm#i1006169
TIMESTAMP WITH LOCAL TIME ZONE Datatype
TIMESTAMP WITH LOCAL TIME ZONE is another variant of TIMESTAMP. It differs from TIMESTAMP WITH TIME ZONE as follows: data stored in the database is normalized to the database time zone, and the time zone offset is not stored as part of the column data. When users retrieve the data, Oracle returns it in the users' local session time zone. The time zone offset is the difference (in hours and minutes) between local time and UTC (Coordinated Universal Time, formerly Greenwich Mean Time).
Thanks
http://swervedba.wordpress.com/ -
Php input date/time as timestamp with timezone
This is a nightmare!!!!
I have numerous databases, all of which use timestamp format
date/times, which are easy to echo according to user timezone
preferences using putenv ("TZ=".$_SESSION['MM_UTZ']); and echo
date($_SESSION['MM_UTF'], ($whatever));
The only problem is, I have only used these for stamping
"date created" or "date edited" values using Time()
What I am trying to achieve is:
User 1 in UK enters date and time, using a javascript
datetime picker (which normally enters data into field in Y-m-d
H:i:s) and the php inserts this in timestamp format according to
timezone.
User 2 in US looks at date and time and this is echo'd
according to his timezone.
Sounds simple...
I have managed to get so far with the new DateTime object
which incorporates the user timezone preference ($utz)
$ndttime= new DateTime($timefield, new DateTimeZone($utz));
I can then echo this effectively using
echo $ndttime->format('$utf'); ($utf being user timeformat
preference)
My stupid problem is trying to get the $ndtime into the
database!!!!
I know this sounds ridiculous but I use the DW insert wizard
which only uses values from a form and if I echo $ndtime into a
hidden field, it doesn't process this value in time.
I attach the current insert script.
Is this simple?
Heeeeelp.quote:
Originally posted by:
AXEmonster
how does this format when you echo to the page
echo $ndttime->format('$utf');
This will echo as a date/time object - i.e. Y-m-d H:i:s, but
the $utf variable is a session variable with user time format
preferences, so it could be D, d/m/Y H:i:s or m-d-Y H:i:s
etc. -
Comparision of TIMESTAMP with TIMEZONE
Hi,
One of the column columnA is of timestamp datetype i.e value stored in it is '2007-09-20 04:00:00.0'
I am using the following in SQL
select * from tableA
where columnA = TO_TIMESTAMP('2011-05-12 21:00:00','YYYY-MM-DD HH24:MI:SS').
This is always returning null results..
Is the syntax correct? Do I need to change the format to accept milli seconds?
Thanks
-Sreewhere columnA = TO_TIMESTAMP('2011-05-12 21:00:00','YYYY-MM-DD HH24:MI:SS').
This is always returning null results..So there is no record with that exact date & time.
Is the syntax correct?yes
Do I need to change the format to accept milli seconds?no -
TimeStamp with time zone vs java Date
In the developer's preview release notes, I read about the extended support on Oracle TimeStamp. We are currently planning to migrate current TIMESTAMP columns to TIMESTAMP WITH TIMEZONE to keep the user time zone with the typed date. Here is my question: Which time zone is persisted using a direct to field mapping between a java.util.Date and a TIMESTAMPTZ column? As the java.util.Date contains no time zone (in opposition to java.util.Calendar), does TopLink uses the JVM time zone? WHat is the best to data structure to keep date/time & time zone in our entities? Thanks, Yannick.
I believe it would be the local timezone of the session. If you map a Date to the TIMESTAMP TZ then the SQL written out will not include a TZ value.
Typically if you wish to map to a TIMESTAMPTZ field you would want to use an object in the model that can hold both the Timestamp and TZ values. This is most commonly a Calendar.
Doug -
More trouble with timezones when storing value in TS WITH LTZ
Using Oracle 9i, JDK 1.4.2.
I have a script using the Jakarta Jelly framework to initialize my db. When I run the script, I want to set the current time in several "TIMESTAMP WITH LOCAL TIME ZONE" columns.
Before the time change, the following excerpt from my script was working fine.
<j:new className="java.util.Date" var="now" />
<j:new className="java.text.SimpleDateFormat" var="format">
<j:arg type="java.lang.String" value="dd-MMM-yyyy hh.mm.ss.SS a Z"/>
</j:new>
<j:set var="ts"
value="cast(cast('${format.format(now)}' as timestamp with time zone) as timestamp with local time zone)"/>
The "Z" in the date/time format produces a 3-letter timezone abbreviation, like "PST" or "PDT".
Before the time change, I was getting "PST" from this, and the code was working fine. When the time change hit, I discovered that Oracle doesn't grok "PDT" (I found info on the internet about this, but I can't find it right now). I thought for a short time on this, and I changed "Z" to "z", which results in "-0700" instead of "PDT". This appeared to work fine. It didn't fail, at least.
However, what I discovered today is that Oracle gets confused by it. It recognizes that as a timezone offset, but it only "half" understands this. When I view the value in SQLDeveloper, it shows a time value 7 hours before the current time, instead of the correct current time as it used to.
I also tried hardcoding a date string, using "US/Pacific", and Oracle groks that, but of course, it doesn't know to use daylight savings time.that makes sense because you are setting the sessionAttribute at the wrong time.. see you are passing the paramater from index to shop, so you really need to set the sessionAttribute in the index page so it is always available in the shop page.
hope that helps...you will always have this problem when refreshing because when you refresh the value from "customer" is not being passed again..... -
XML dateTime type with timezone info.
Has anyone have problem FTPing xml that conforms to a xml schema with dateTime type?
This is the format of standard XML dateTime type:
"2003-12-17T09:30:47-05:00"
I used the Oracle timestamp datatype, but oracle rejected the dateTime of XML with the error message
"ORA-01830: date format picture ends before converting entire input string."
I have altered the database to use timezone information:
// For eastern time zone.
alter DATABASE SET time_zone = 'Etc/GMT-5';
and use the native oracle datatype
"TIMESTAMP WITH TIME ZONE"
but still doesn't work. I also changed the XML time data to "2003-12-17 09:30:47-05:00", still no good.I tried couple formats, they all seem to need the "T" in between date and time. If I don't have the "T", I get the error message "ORA-01861: literal does not match format string"
If I use the following input I get the error message
"ORA-31041: Property CreateDate: Memory type (180) not compatible with database type (121)"
"2003-12-11T21:30:47.0"
"2003-12-11T21:30:47.000000"
"2003-12-11T21:30:47.000000000"
"2003-12-11T21:30:47000000"
"2003-12-11T21:30:470000"
If I use the following I get error message "ORA-01830: date format picture ends before converting entire input string"
"2003-12-11T21:30:470000-04:00"
"2003-12-11T21:30:47.000000-05:00"
"2003-12-11T21:30:47.0-05:00"
It leads me to think that "2003-12-11T21:30:47.000000"
is the picture(mask) used by the database. But it has extra "T" in it, and oracle doesn't understand the datatype. Maybe there are two validation going on? one from schema and another during insertion to database? Schema requires "T", but database doesn't understand "T"?
Am I in the right track?
Do you know how do I query the mask used?
Thanks,
--Benjamin -
I'm using a Oracle 9.2 database and Oracle 9 JDBC drivers.
The server has its time zone set to GMT and I'm testing from a client in EST.
It seems like the Timestamp are not being returned correctly.
What I think is happening here is mismatch between the time zone of Oracle server and the client that is not being accounted for when the driver is creating timestamps.
If I add the row using sysdate at 8 AM EST on a server running on GMT, then retrieve the timestamp with JDBC using a Java default time zone of EST, I get a timestamp that matches 1 PM EST or 6 PM GMT.
If I retrieve it with JDBC after setting my Java default time zone to GMT (so it matches the server), then I get a timestamp that matches 8 AM EST or 1 PM GMT which is correct.
My hunch is that the driver is just doing a new Calendar and setting the hour directly from the server. So if the server passes 1 PM (or hour 13 in 24 hour day), it just sets it using the default time zone whatever it is. As long as the client default time zone and the Oracle server time zone are the same, everything works fine. If they are different, there will be a discrepancy of the number hours offset between the time zone of the client and the time zone of the server.
Does any one else have any ideas?First, I am not setting the timestamp without
conversion (#2). The driver is setting the timestamp
and you are suggesting exactly what I think the
driver is doing.
As I understand it, timestamp has NO timezone. It is,
in fact, a long number of milliseconds since Jan 1,
1970 GMT.
Timezones come into play when we go to render the
milliseconds in a way that makes sense ot humans.
In other words, the timestamp for 8 AM EST and 1 PM
GMT are the same. If you don't believe it, create two
Calendar objects, one with EST timezone and the other
with GMT. Set the GMT one to 1 PM and the other one
to 8 AM (same day, year, minutes, and milliseconds).
Then display the time as a long. It is the same value.Correct. -
Timestamp with a better resolution
Hello!
if i didn't omit something, Oracle 8.1 has a resolution
of only 1 sec. for timestamps. Is there any type with
a better resolution?
(even a clear "NO" would be of great help)
Thank you!
AUrelian CoasanWhile this will not help you with Oracle8i, in 9i, there is a built-in type called timestamp (comes in 3 flavours, plain, with timezone, and with local timezone) which has fractional second accuracy.
Ciao
Daniel -
Display UTC-Timestamp in timezone of user/server
Hello,
the view of my WD Component displays UTC-Timestamps in a table (Cell Editor LinkToAction).
The user has the possibility to alter the timestamps by providing date and time.
The controller converts date and time to a UTC-timestamp by using ABAP-Statement CONVERT with timezone of server (sy-zonlo).
The timezone is CET (UTC1). Therefore the fields to enter the time is displayed in UTC1 but the timestamp is displayed as UTC. The user might be confused, because when entering a time in the inputfield, the timestamp will be displayed 1 hour in the past.
The domain of the timestamp is TZNTSTMPS. I also tried to convert the timestamp into a field with domain TZNTSTMPSL, but with the same effect.
Is there a possibility to display the timestamp in the timezone of the server (sy-zonlo) or in the timezone of the user?
Thanks in advance
PatrickThank you Phil,
I already use both commands.
The user can enter a date and time which is already displayed in his timezone (use of command CONVERT TIMESTAMP ... and later when user saves his settings use of command CONVERT DATE lv_date TIME lv_time ...).
The date and time that user has given should be displayed as a timestamp later(LinkToAction in a table column).
Hope I made the problem clear. The date and time that the user can enter is already displayed in his timezone. It's just about the timestamp which is displayed after user has given date and time. That timestamp should be also displayed in the timezone of the user and not in UTC.
Thanks for your help so far.
Patrick
Maybe you are looking for
-
How to get the nber of POs at the item level?
Hi all, I am running BI 7 and SRM 5.5. I am using the standard PO History cube. I have a report where I filter on items values only (no header) since I want to report by - let's say - product category. In my char part, I will have: Date | product cat
-
Javascript void with all my browsers
i started using some java based sites and they worked fine but one day alot of the sites i used no longer would comply with whatever id click or some pages wouldnt load at all and i get a Javascript::void(0) message at the bottom of the screen. ive e
-
Playing songs in library on desktop computer - songs won't auto advance
OK, I realize that this might rank right up thee under all time dumb questions... I am sitting at my desktop computer and just want music playing from my Library in the background. A single song plays, and it doesn't automatically shuffle to a new so
-
It is Possible to get Preflight information using javascript...?
Hi EveryOne!!! I'm new baby to Acrobat using javascript .Please Help me? It is Possible to get Preflight information(trim size, colorspace and fonts) using javascript...? Thanks in Advance. -yajiv
-
Can't connect to server internally when external internet goes out
Whenever our internet service goes down, we can't even connect to our internal server through our own internal network. As soon as our external internet service comes back up, we can connect just fine. I can't figure out why the two would be related