Cast to timestamp

Hello,
OBIEE 11.1.1 answers question.
To recover full date time accuracy from a number of date / time elements I have concatenated up date / time elements to give me a full char version of a timestamp, however when I try to convert it to a timestamp to perform a calculation on it I get a general error, even though when I convert a timestamp to a char I see an identical date / time string in the format dd/mm/yyyy hh:mi:ss i.e. 31/01/2011 15:32:26
I have also tried switching the char datestring around to yyyymmdd.
Does anyone know the secret, the code examples from the manuals just do not work for timestamp as they say they should, i.e. you cannot cast a date directly to stamp, but you can cast it via a char to timestamp....
A simple example of converting a literal to a timestamp (including hours / minutes / seconds) would be ideal here.
And yes, I know this would be best created in the repository not in analytics.
many thanks,
Robert.

Okay, I have answered my question, the timestamp format seems to be; -
cast( '31-DEC-01010203' as timestamp)
Where this would equate to the 31st December 2001 01:02:03 (just after 2 minutes past 1 in the morning).
But...
Still my function bombs when I feed concatenated values into it, even though when I look at the results for the filter applied all of them - pre casting to timestamp - conform to my "format mask" above.
Does this mean that even though all of my values evaluate properly the function is being applied to ALL values before any (independent) filters are applied??
Is there anyway to gracefully handle these kind of cast errors - the logical equivalent of; -
on error (cast("my folder"."my character date" as timestamp) then cast('01-DEC-51000001' as timestamp)
thanks for any pointers on this, appreciated.
Robert.

Similar Messages

  • Sys_extract_utc, sysdate and cast to timestamp

    I have a question about sys_extract_utc.
    According to this document:
    http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions167.htm
    SYS_EXTRACT_UTC function entry is a datetime_with_timezone.
    so... running this in my system:
    1) select TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI') as mysysdate from dual;
    MYSYSDATE
    2013-05-14 20:27
    2) select TO_CHAR(systimestamp, 'YYYY-MM-DD HH24:MI TZR') as mysystimestamp from dual;
    MYSYSTIMESTAMP
    2013-05-14 20:27 +03:00
    3) select TO_CHAR((cast (sysdate as timestamp)), 'YYYY-MM-DD HH24:MI TZR') as cast_sysdate_timestamp from dual;
    CAST_SYSDATE_TIMESTAMP
    2013-05-14 20:17 +00:00
    4) select TO_CHAR(sys_extract_utc(cast (sysdate as timestamp)), 'YYYY-MM-DD HH24:MI TZR') as utc_time from dual;
    UTC_TIME
    2013-05-14 17:27 +00:00
    Questions:
    How is it possible to have the query 4) correct... if the cast of sysdate to timestamp in 3) does not have the correct timezone has you can see in query 3) !?
    Where does sys_extract_utc collects the information, in order to make query 4) correct?
    Edited by: PauloSMO on 14/Mai/2013 10:37

    The reason you are seeing cast (sysdate as timestamp) with a time zone of +00:00 is because you cast it to a timestamp without time zone. When you displayed it with a TZR it gave the +00:00 because there is no zone - it's a zone-less timestamp. SYS_EXTRACT_UTC requires a timestamp with time zone as its parameter so it casts the timestamp to timestamp with time zone which puts it into the local time zone +3. The Oracle 11.2 documentation of SYS_EXTRACT_UTC has added
    If a time zone is not specified, the time is associated with the database time zone.The output of SYS_EXTRACT_UTC appears to be TIMESTAMP (no time zone).
    You should have cast(sysdate as timestamp with time zone) to get the equivalent of systimestamp:
    On my system (running GMT + 10)
    1. select cast(sysdate as timestamp) from dual;
    16-May-2013 09:52:56.00  -- that's using my NLS_TIMESTAMP_FORMAT
    2. select cast(sysdate as timestamp with time zone) from dual;
    16-MAY-13 09.52.50.000000 AM +10:00  -- that's using my NLS_TIMESTAMP_TZ_FORMAT format
    3. select to_char(cast(sysdate as timestamp), 'YYYY-MM-DD HH24:MI TZR') from dual;
    2013-05-16 09:59 +00:00  -- the +00:00 is meaningless - a timestamp doesn't have a time zone.
    4. select to_char(cast(sysdate as timestamp with time zone), 'YYYY-MM-DD HH24:MI TZR') from dual;
    2013-05-16 09:59 +10:00  -- +10:00 is my real time zone.
    5.  select sys_extract_utc(cast(sysdate as timestamp with time zone)) from dual;
    16-May-2013 00:05:43.00  -- Incidentally, notice the lack of a time zone here - it's a TIMESTAMP without time zone, using my NLS_TIMESTAMP_FORMATregards,
    David
    Edited by: davidp 2 on May 15, 2013 5:11 PM

  • Cast a timestamp to date in a "where" clause

    Hi everybody :)
    I've got a little problem that seems very simple, but I can't solved it myself :(
    I've got a column with a "timestamp" format, and I'd like to select all the records that are from a precise date, let's say "12/14/2009".
    I have the following SQL statement :
    SELECT * FROM myTable WHERE (CAST (myTimestampField AS DATE))= TO_DATE('12/14/2009', 'mm/dd/yyyy')
    But that returns me nothing... However, I've got records with timestamps that where created the 14th of december.
    Can you help me with that, I'm really out of ideas... And I'm not a SQL expert :p
    Thanks a lot!

    what is the bbcode for the code ? simple code ?write before and after your code snippet.
    Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/02/query-gerarchiche/]                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Cast Timestamp to Date ?

    Hello,
    Is i ok to cast a Timestamp to a Date ?
    Olek
    Edited by: Olek on Nov 10, 2007 5:15 PM

    Olek wrote:
    java.util.Date or java.sql.Date
    Olekjava.sql.Date extends java.util.Date and
    java.sql.Timestamp extends java.util.Date
    So you cannot "cast" Timestamp to java.sql.Date. Try it and you will get a compiler error:
    java.sql.Timestamp ts = ...;
    java.sql.Date date = (java.sql.Date) ts; //error: inconvertible types

  • OBIEE Cast as char,timestamp erroring

    Hi,
    I AM ABLE to use the cast as char and then cast as timestamp function on 2 date columns to get the time diffrnc using timestampdiff. This is on an ebs 11 instance database.
    As we are upgrading to EBS R12, we set up a new test instance of obiee on this. But in this new test instance, the same formula is erroring out.
    The date is in format yyyy/mm/dd. After cast as char , i get it in format mm-dd-yyyy in both instances. But on cast as timestamp,in the new (r12) instance i get the error
    Oracle Error code: 1843, message: ORA-01843: not a valid month at OCI call OCIStmtFetch. [nQSError: 17012] Bulk fetch failed. (HY000)
    I tried passing date in the format 'dd-mon-yy' (char format) in the r12 instance and then cast it timestamp and this seems to work. Why is the bi server expecting date in this format after char and how can i change this?
    note:the nls_date_formats are same in both the database.
    the date formats in both the nqsconfig.ini files are also same
    any other place where i should set this?

    Try to search the xml for the same code and replace using Catalog Manager.
    Using Catalog Manager find your old code which is using cast as char and replace with new code for more details see
    http://docs.oracle.com/cd/E23943_01/bi.1111/e10541/prescatadmin.htm#i1046286
    Since given suggestion worked can you mark as correct on my last response?
    Edited by: Srini VEERAVALLI on Apr 1, 2013 9:46 AM
    Edited by: Srini VEERAVALLI on Apr 1, 2013 9:52 AM

  • Using timestamp in union all view

    I am having a silly problem with one of my views. It is a union all with two select statements. There is a timestamp(6) in one select but not in the other so I have a to_timestamp(null) to match up the columns.
    The problem is that no matter how I code the to_timestamp(null,fmt) the structure of the view is always timestamp(0). I even changed the 2nd select so that it uses a timestamp(6) column. If I create 2 views from both selects they have the correct syntax but as soon as I use a union the timestamp loses it precision.
    When I acutally do a select from the view I can still see the milliseconds precision. My real problem occurs in that I have a ref cursor that is of type view_row%rowtype. When I select into the cursor I lose the precision.
    Any ideas?
    thx

    Use the cast function to cast the timestamp to timestamp(6)
    SQL> create table t
    2 ( id number
    3 , ts timestamp(6)
    4 );
    Table created.
    SQL> create view v
    2 as
    3 select id, ts
    4 from t
    5 union all
    6 select 0, cast(to_timestamp(null) as timestamp(6))
    7 from dual;
    View created.
    SQL> desc v
    Name Null? Type
    ID NUMBER
    TS TIMESTAMP(6)
    SQL> insert into t
    2 values (1,systimestamp);
    1 row created.
    SQL> select * from v;
    ID
    TS
    1
    31-AUG-04 02.28.38.342412 PM
    0

  • Variable Date type

    Hello,
    I have a date type variable like 05/07/2008 / day/month/year and it works as a string.
    I have a prompt with this date type where I have declared a variable called v_date.
    The problem is how to make a filter in a form with this variable to see actual year and the previous year.
    I have done it many times with other variables like integers or floats like this:
    xxxxxxxx IN (@{v_date},(@{v_date}-1))
    where v_date is an integer variable type.
    I guess I have to convert the string to int with functions like cast and substring to use the formula but it hasn't worked.
    Thank you for your help!

    Thank you for your answer but still not working.
    This is what I have written in my filter of my report:
    "Dim Fecha Dia Curso"."Day Date" IN (Right(@{v_date}, 4),(Cast(Right(@{v_date}, 4) as int) - 1))
    and that's the error I've recieved:
    View Display Error
    Odbc driver returned an error (SQLExecDirectW).
    Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 932, message: ORA-00932: inconsistent data types: wait for DATE and got NUMBER at OCI call OCIStmtExecute. [nQSError: 17010] SQL statement preparation failed. (HY000)
    SQL Issued: SELECT "Dim Fecha Dia Curso"."Dia Date" saw_0, "- Actuales"."Nº Cons Revisión" saw_1 FROM Volumen WHERE ("Dim Dpto Resp"."Centro Resp" = 'NAV') AND ("Dim Fecha Dia Curso"."Dia Date" IN (Right( TIMESTAMP '2010-01-27 00:00:00', 4),(Cast(Right( TIMESTAMP '2010-01-27 00:00:00', 4) as int) - 1))) ORDER BY saw_0
    I've translated a couple of sentences in the error because I recieved the error in spanish.
    I hope to help you in the translation.
    Thanks!

  • ALC-ASM-S00-002 NumberFormatException on attachment filename or source

    DDX:
    <DDX xmlns="http://ns.adobe.com/DDX/1.0/">
      <PDF result="pdfWithAttachments" format="PDF">
       <PDF source="pdfWithoutAttachments"/>
       <FileAttachments source="pic_20140917135051.bmp">
        <File filename="pic_20140917135051.bmp"/>
        <Description>null</Description>
       </FileAttachments>
      </PDF>
    </DDX>
    Error:
    INFO  [com.adobe.livecycle.assembler.AssemblerServiceImpl] ALC-ASM-N00-001: Execute: invoke() begin on thread WorkerThread#1[192.168.126.196:59718] 186
    INFO  [com.adobe.internal.ddxm.Executive] DDXM_N00000: Started processing result named pdfWithAttachments
    ERROR [com.adobe.internal.ddxm.Executive] DDXM_S00001: Failed to assemble result named pdfWithAttachments
    ERROR [com.adobe.livecycle.assembler.AssemblerServiceImpl] ALC-ASM-S00-002: Failed to execute the DDX - error messages provided.
    com.adobe.livecycle.assembler.client.ProcessingException: ALC-ASM-S00-002: Failed to execute the DDX - error messages provided.
    at com.adobe.livecycle.assembler.AssemblerServiceImpl.makeResult(AssemblerServiceImpl.java:906)
    at com.adobe.livecycle.assembler.AssemblerServiceImpl.execute(AssemblerServiceImpl.java:510)
    at com.adobe.livecycle.assembler.AssemblerServiceImpl.invoke(AssemblerServiceImpl.java:454)
    Caused by: java.lang.NumberFormatException: For input string: "20140917135051"
    at java.lang.NumberFormatException.forInputString(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at com.adobe.internal.pdfm.embeddedfiles.EmbeddedFilesHandler.updateBaseDocEmbeddedFilenames(EmbeddedFilesHandler.java:947)
    at com.adobe.internal.pdfm.embeddedfiles.EmbeddedFilesHandler.addEmbeddedFile(EmbeddedFilesHandler.java:691)
    at com.adobe.internal.pdfm.embeddedfiles.EmbeddedFilesHandler.importEmbeddedFiles(EmbeddedFilesHandler.java:285)
    at com.adobe.internal.pdfm.attachments.Attachments.importAttachments(Attachments.java:370)
    at com.adobe.internal.ddxm.task.attachments.ImportAttachments.execute(ImportAttachments.java:216)
    at com.adobe.internal.ddxm.ddx.Node.execute(Node.java:353)
    The assembler is parsing the filename or source string (not sure which) and cast the timestamp part to a number ??
    The assembler proces works fine with source and filename "pic_1.bmp"
    Livecycle ES2.0

    UPDATE
    We have installed a new UTF-8 database (Oracle) because the original database was not a unicode database.
    Now the process starts, we no longer get the errors in the server.log
    But now the parameter that contains the mail attachment (pdf) is empty.
    For a normal pdf (no special characters) the parameter is not empty.
    When we change the endpoint by changing the input parameter mapping from *.pdf to * we are able to
    receive the attachment in the input parameter.
    The reason is that the filename (ex. éa.pdf) is being changed to something like "=?ISO-8859-1?Q?=E9a=2Epdf?=".
    Hereby *.pdf does not match and the parameter is empty.
    By changing the endpoint we are now allowing all types of attachments. (ex. xls, doc,..)
    We only want pdf documents.
    In the proces we can get the documentname by using getDocAttribute(/process_data/@inPdfDoc, "wsfilename").
    Since this returns "=?ISO-8859-1?Q?=E9a=2Epdf?=" it's not clear what kind of document this is.
    For é.pdf, "=?iso-8859-1?B?6S5wZGY=?=" is begin returned (not even the letters "pdf").
    Does anyone know a way to solve this?
    Does anyone know a way to get the type of the attachment since the documentname is not a solution...

  • Log an arbitrary waveform to TDMS

    I'm trying to log an arbitrary waveform (one that is not time-based, e.g. x0 = -180, dx = 0.25) to a TDMS file.  For some reason I can't figure out how to do this.  It appears that I am only able to log time-based waveforms to a TDMS file. I tried to cast my x0 to a timestamp but it coerces negative values to a zero timestamp.  I have all my data being displayed on waveform graphs perfectly fine with a x0, dx, Y cluster.
    So, is there a way to log my waveform to TDMS without requiring any post-processing?

    If you cast a negative to timestamp, LabVIEW doesn't coerce negative values to a zero timestamp. By default, 0 means timestamp '0:00:00 AM 1/1/1904', so -180 will be casted to timestamp as '11:57:00 PM 12/31/1903'. The number is treated as seconds.
    TDMS only accepts time-based waveforms. If you want to give different meanings to the t0 and dt of the waveform, you should need some post-processing. In TDMS files, t0 will be mapped to 'wf_start_time' property, dt will be mapped to 'wf_increment' property. At the same time, TDMS file will add another property 'wf_start_offset'. So, if you treat t0 as 0, then you can set  'wf_start_offset' property as -180 to meat your requirement.

  • Java.utl.Date.equals()

    here is my code..
          java.util.Date d1 = (java.util.Date)resultsetObj.getTimestamp(1);
          java.util.Date d2 = some_date;
          //some_date is equal to date in database fetched using getTimestamp()
          if(d1.equals(d2))
               System.out.println("Equal");
          else
               System.out.println("Not Equal");Now why does the program prints "Not Equal" even if d1 and d2 are equal?

    With the code you posted, the method that gets called is Date.equals.
    Overriding the equals() method can be complicated when there is inheritance.
    The contract of the equals method requires it to be symmetric -- that a = b implies b = a
    That is, if date.equals(timestamp) is true, so should be timestamp.equals(date).
    Equals must also be transitive -- that a = b and b = c imply a = c.
    That is, if date.equals(timestamp1) and date.equals(timestamp2) were true, so should be timestamp1.equals(timestamp2).
    Now the problem is: Timestamp consists of a Date and a number of nanoseconds. So how should one implement equals in Date and Timestamp?
    Let�s consider the Date class. If you treat Timestamp as a kind of a Date and ignore the nanosecond-part, from symmetry and transitivity it follows that all Timestamps with the same Date part should be equal, no matter what their nanoseconds were. So the equals method in Date should do a check like "if (obj instanceof Timestamp) { cast to Timestamp and consider the nanosecond part }" --- which is very bad from the OO perspective; a superclass should not be aware of its subclasses. This is why most of the time when you implement equals() in a superclass it should return false for objects of subclasses.
    Hence Date and Timestamp are not really interchangeable. This is the meaning of the sentence "the inheritance relationship between Timestamp and java.util.Date really denotes implementation inheritance, and not type inheritance" --- you cannot treat Timestamps like Dates; there is no type inheritance. Timestamp is a subclass of Date only for the benefit of inheriting lots of methods.

  • Using CAST function to convert to timestamp

    I have a select statement that runs via JDBC and is not using any index as timestamp is explicitly used. I would like to be able to convert to Date so the proper index can be used as this column is of Date datatype. I'm having "ORA-25137: Data value out of range" when I use "b.TRAN_DATE BETWEEN CAST(:1 AS DATE) AND CAST(:2 AS DATE) : instead of "b.TRAN_DATE BETWEEN :a and :b.
    Could someone help with this as I really want our indexes to be used and therefore Date datatype should be used in the JDBC connection
    Thanks

    Below is the query that is not using the index b/c of the date datatype. Changing b.TRAN_DATE BETWEEN :1 AND :2 to b.TRAN_DATE BETWEEN CAST(:1 AS DATE) AND CAST(:2 AS DATE) gives "ORA-25137: Data value out of range" error.
    SELECT
    a.CURRENCY_ID D_161,
    a.CURRENCY_NAME D_201,
    b.TRANS_TYPE_NAME D_22,
    UPPER(b.TRANS_TYPE_NAME) S_22,
    REPORT.MASK_CARD(b.CARD_NUMBER, b.TRANS_TYPE_ID) D_142,
    REPORT.MASK_CARD(UPPER(b.CARD_NUMBER), b.TRANS_TYPE_ID) S_142,
    b.TRAN_DATE D_440,
    b.VEND_COLUMN D_54,
    UPPER(b.VEND_COLUMN) S_54,
    c.LOCATION_NAME D_16,
    UPPER(c.LOCATION_NAME) S_16,
    d.EPORT_SERIAL_NUM D_60,
    UPPER(d.EPORT_SERIAL_NUM) S_60,
    b.DESCRIPTION D_58,
    UPPER(b.DESCRIPTION) S_58,
    SUM(b.TOTAL_AMOUNT) D_51_SUM,
    a.CURRENCY_SYMBOL D_181,
    SUM(b.QUANTITY) D_55_SUM,
    a.CURRENCY_CODE D_182
    FROM
    CORP.CURRENCY a,
    REPORT.ACTIVITY_REF b,
    REPORT.EPORT d,
    REPORT.LOCATION c,
    REPORT.TERMINAL f,
    REPORT.VW_USER_TERMINAL e
    WHERE ((b.TRAN_DATE BETWEEN :1 AND :2
    AND b.CARD_NUMBER = :3)
    AND e.USER_ID = :4)
    AND b.CURRENCY_ID = a.CURRENCY_ID
    AND b.EPORT_ID = d.EPORT_ID
    AND b.LOCATION_ID = c.LOCATION_ID
    AND f.TERMINAL_ID = e.TERMINAL_ID
    AND b.TERMINAL_ID = f.TERMINAL_ID
    GROUP BY
    a.CURRENCY_ID,
    a.CURRENCY_NAME,
    b.TRANS_TYPE_NAME,
    UPPER(b.TRANS_TYPE_NAME),
    REPORT.MASK_CARD(b.CARD_NUMBER, b.TRANS_TYPE_ID),
    REPORT.MASK_CARD(UPPER(b.CARD_NUMBER), b.TRANS_TYPE_ID),
    b.TRAN_DATE,
    b.VEND_COLUMN,
    UPPER(b.VEND_COLUMN),
    c.LOCATION_NAME,
    UPPER(c.LOCATION_NAME),
    d.EPORT_SERIAL_NUM,
    UPPER(d.EPORT_SERIAL_NUM),
    b.DESCRIPTION,
    UPPER(b.DESCRIPTION),
    a.CURRENCY_SYMBOL,
    a.CURRENCY_CODE
    ORDER BY
    D_161 ASC,
    D_201 ASC,
    S_22 ASC,
    S_142 ASC,
    D_440 ASC,
    S_54 ASC,
    S_16 ASC,
    S_60 ASC,
    S_58 ASC,
    D_51_SUM ASC,
    D_181 ASC,
    D_55_SUM ASC,
    D_182 ASC

  • Does CAST ( date as timestamp) causes performance issues

    Hi
    does casting from DATE to TIMESTAMP in a query or in a view causes the slow down of performance??
    Please guide...
    Thanks
    Rimpi

    Everything you do affect performance. How significantly is a question answered by testing not by asking questions on an OTN forum.
    Create a loop doing it 10,000 times and find out.
    And, in the future, always include your version number.

  • Date shows timestamp with cast function

    hi,
    i am entering date from java to oracle, when i used CAST function to convert as TIMESTAMP it shows the correct time in ONE DB environment.
    But the same date not showing proper time in another DB environment.
    It always shows 12.00.00.000000
    shall i want to set any values in db level.
    QL> SELECT CAST(MKR_DT AS TIMESTAMP) FROM NAAP30_APPPRODUCTS WHERE APPLICATION_ID=2007020026410;
    CAST(MKR_DTASTIMESTAMP)
    20-FEB-07 12.00.00.000000 AM
    Please advice...
    Thanks in advance
    siva

    I already gave you a hint on
    Re: DATE WITH TIMESTAMP

  • How to get the last received notification timestamp when app in background

    Hi All,
    We are developing the app in windows phone Silverlight 8.1.
    We need to show the last received notification time stamp even when the app is in background.
    When the app in foreground, I can get the timestamp.
    Since we cant write the background task for the Silverlight phone 8.1 app, I don't know how to get the time stamp of the last
    notification(toast/livetile/badge) in the app for display.
    Can anyone help on this.
    Thanks,
    Meena

    Yes, continuous background execution is not supported but you can use background tasks. 
    (Continuous background execution in this context refers to the special run state permitted for GPS Navigation apps.)
    For information regarding Background Tasks see: Supporting your app with background tasks -
    http://msdn.microsoft.com/library/windows/apps/hh977046.aspx
    Additional information is available in these topics:
    Guidelines for background tasks
    PushNotificationTrigger
    How to receive raw notifications
    Eric Fleck, Windows Store and Windows Phone Developer Support. If you would like to provide feedback or suggestions for future improvements to the Windows Phone SDK please go to http://wpdev.uservoice.com/ where you can post your suggestions and/or cast
    your votes for existing suggestions.

  • How can I convert SQL Server 2008 Timestamp to DB2/iSeries Timestamp?

    In DB2/iSeries I have a column that accepts Timestamp value. When I try to insert a timestamp value from the SQL 2008 table and into DB2/iSeries table I recieve the following error message:
    OLE DB provider "IBMDA400" for linked server "XXX" returned message "SQL0180: Syntax of date, time, or timestamp value not valid.
    Cause . . . . . :   The string representation of a date, time, or timestamp value does not conform to the syntax for the specified or implied data type and format. *N is either the character string constant that is not valid or the column or host
    variable that contained the string. If the name is *N, then the value is an expression specified in the statement. If the string was found in a host variable, the host variable number is 1. Recovery  . . . :   Ensure that the date, time, or
    timestamp value conforms to the syntax for the data type it represents. Try the request again.".
    Msg 7343, Level 16, State 2, Line 1
    The OLE DB provider "IBMDA400" for linked server "XXX" could not INSERT INTO table "[IBMDA400]".
    The SQL timestamp column contains the result in the following format:
    2014-04-24 07:39:09.000
    And my insert TSQL command is:
    INSERT INTO OPENQUERY(XXX, 'Select "TimeOfDeal" from ABCD.TICKETS')
    SELECT TimeOfDeal
    FROM dbo.Tickets
    WHERE DealId = 'ABC123'
    I appreciate any help on this issue.

    You are right it is a datetime data type in MS SQL, and a Timestamp in DB2. 
    I cast it to datetime2 and it worked.
    Interesting. I would guess that somewhere under the covers, the date value gets converted to a string, and the different default string formats for datetime and datetime2 is illustrated with this statement:
    SELECT convert(varchar, getdate()), convert(varchar, sysdatetime())
    When I ran it, I got these values:
    Feb 23 2015 12:31PM      2015-02-23 12:31:18.3708899
    Now, why there is a conversion to string in the first place, I'm afraid I don't have any good answer to.
    Erland Sommarskog, SQL Server MVP, [email protected]

Maybe you are looking for