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

Similar Messages

  • 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/]                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to convert a timestamp to date/time in CDS View?

    Dear experts,
    I would like to convert a timestamp to a date and time within a CDS view.
    This is what I tried to do:
    Cast (Cast(<timestamp> as abap.dec(8,0)) as abap.dats) as <date>
    I also thought about first converting the timestamp into a plain numerical character, then using substring and then casting it to abap.dats. Then its giving me an error that says: "dec can't be converted into numc".
    The above written code also throws an error - "function not allowed/ no cast within a cast".
    It is quite nasty not being able to write a cast within a cast - how else am i supposed to achieve a date here?
    I am looking forward to have your answers!
    Thanks and BR
    Anja

    Hi Anja,
    what you try to do is currently not possible, a feature not available in CDS views.
    Yet it surely is a feature, ABAP developers would like to see on the feature request list .
    Cheers,
      Jasmin

  • Timestamp vs date datatype

    I am transferring data from table A to table B. there is a column in table A with datatype 'timestamp' that has the fraction seconds in the data. However I am using data type 'date' in table B where I am transferring the timestamp data to. I can query the fraction saconds using the hh:mm:ss.ff in table A but when I use it in table B it shows nothing and errors out.
    i tried to use the CAST function to query the fraction seconds in table B but it shows zeroes.
    question is - is the fraction second being transferred to table B? what can I do to make sure fractions are being transferred from A to B
    any help will be appreciated

    Hi,
    question is - is the fraction second being transferred to table B? what can I do to make sure fractions are being transferred from A to BThat is the one of the difference between TIMESTAMP and DATE. TIMESTAMP holds the miliseconds also. To transfer fraction of second you need to convert B table's datatype to TIMESTAMP.
    Cheers,
    Avinash

  • In my opinion, the real solution is for Apple to offer us a choice of the photo sort order in ITunes. My preference would be filename, perhaps with options to choose the Date Taken attribute, file timestamp or date modified filestamp (EXIF date fields as

    I tryed to sort my pictures with buying Apps and following suggestion from apple, but without any success. In my opinion, the real solution is for Apple to offer us a choice of the photo sort order in ITunes. My preference would be filename, perhaps with options to choose the Date Taken attribute, file timestamp or date modified filestamp.

    Not a problem when using iPhoto on a Mac, which the transfer of photos is primarily based on - not manually managing photo storage as seems to be common with Windoze.
    The same should be available with a supported photo management app on a PC.
    http://support.apple.com/kb/HT4221

  • Timestamp vs date

    Hello All ,
    I want to compare a timestamp with a date
    my query is
    SELECT Calendar.DESCRIPTION,
           Calendar.END_DATE,
           Calendar.ID,
           Calendar.PROVIDER,
           Calendar.REMINDER,
           Calendar.START_DATE
    FROM CALENDAR Calendar
    WHERE   ( (UPPER(Calendar.REMINDER) = UPPER('ON') ) AND (TO_CHAR( TO_TIMESTAMP(Calendar.START_DATE), 'yyyy-mm-dd hh24:mi:ss.ff') = TO_CHAR('sysdate+1/24') ) ) any help ?
    thanks

    Faraj wrote:
    hello stefan ,
    <font style="color: green; background-color: #ffff42">I can not cast the start_date. </font>I can only cast or edit the sysdate. as i said I am using jdeveloper and I am creating a criteria view so I want tje start_date to be equale to the current date + 1 hour. when I write that I got an error.
    any help?I didn't casted start_date.. ツ
    stefan nebesnak wrote:
    Faraj wrote:
    1- start_date is of type timestamp
    2- i tried to_char and to_timestamp and things did not went correct.Try this:
    (not tested)
    start_date > CAST (SYSDATE + 1/24 AS TIMESTAMP)
    SQL> select CAST (SYSDATE + 1/24 AS TIMESTAMP) from dual;
    CAST(SYSDATE+1/24ASTIMESTAMP)
    15.02.13 13:02:59,000000

  • Converting unix timestamp to date after Daylight Saving Time change

    Hello,
    in one of the products we use the internal scheduler stores dates (and times) in an Unix-like format, that is seconds since 1st of January 1970. We have used this SQL to extract the actual date:
    TO_CHAR(t.next_fire_time/(24*60*60*1000) +to_date('19700101020000','yyyymmddhh24miss'),'yyyymmddhh24miss')
    Everything worked fine until the time has changed this weekend from UTC+2 to UTC+1 (we are located in Eastern Europe). Since then the query above returns one hour later than it should.
    I.e. timestamp *1320067800000* is returned as *20111031153000* even thought correct is (and the actual time the event was scheduled) *31-OCT-11 02.30.16.000000 PM*
    I found queries like this on different forums and no one seems to worry much about the daylight savings. Is this a configuration issue in the DB or is it a bug in our code?
    I tried selecting the SESSIONTIMEZONE and DBTIMEZONE and both were +1.
    Any help appreciated.

    Your problem is hard-coded 2hour offset:
    to_date('19700101<font size=5 color=red>02</font>0000','yyyymmddhh24miss')You need to calculate current offset to adjust it to current DST situation:
    with sample_table as (
                          select date '1970-01-01' + 1320067800000 / 1000 / 3600 / 24 dt_utc from dual
    select  dt_utc,
            dt_utc +
            extract(
                         timezone_hour
                    from
                         from_tz(cast(dt_utc as timestamp),'utc') at time zone 'Europe/Prague'
                   ) / 24 dt_prague,
            extract(
                         timezone_hour
                    from
                         from_tz(cast(dt_utc as timestamp),'utc') at time zone 'Europe/Prague'
                   ) tz_offset
      from  sample_table
    DT_UTC              DT_PRAGUE            TZ_OFFSET
    2011-10-31 13:30:00 2011-10-31 14:30:00          1
    SQL> SY.

  • Online redefinition timestamp to date column. Impossible ?

    Hi ,
    I'm trying to online redefine timestamp column to date column (cut off fractional seconds) but looks like this is
    impossible at least in 9.2 EE DB.
    SQL> desc t
    Name                                                                                      Null?    Type
    ID                                                                                        NOT NULL NUMBER
    DATA                                                                                               TIMESTAMP(6)
    SQL> desc t_interim
    Name                                                                                      Null?    Type
    ID                                                                                        NOT NULL NUMBER
    DATA                                                                                               DATE
    declare
    l_colmap varchar2(512);
    begin
    l_colmap := 'id , data cast(data as date)';
    dbms_redefinition.start_redef_table(user, 'T' , 'T_INTERIM', l_colmap);
    end;
    declare
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expected
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 8
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 146
    ORA-06512: at line 5Regards.
    Greg

    SQL> select to_timestamp_tz('2011-03-10T13:55:00.000-06:00','YYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') from dual
      2  /
    TO_TIMESTAMP_TZ('2011-03-10T13:55:00.000-06:00','YYYY-MM-DD"T"HH24:MI:SS.FF
    10-MAR-11 01.55.00.000000000 PM -06:00
    SQL>  SY.

  • Class Cast Exception for Date Format .

    Hi Friends ,
    I am getting a error for casting type from Object to Date type .
    Could you please some one help me . I am using a prepared statement in OAF for inserting a data .
    All fields are inserting except Date format .
    My code in controller as follows :
    try {    String StartDate=row.getAttribute("StartDate").toString();
    // String StartDate="30-Apr-2011";
    DateFormat formatter ;
    Date StartDate1;
    formatter = new SimpleDateFormat("dd-MMM-yy");
    StartDate1 = (Date)formatter.parse(StartDate);
    //System.out.println("Today is " +date );
    pstmt.setDate(12,StartDate1);
    } catch (ParseException e)
    {System.out.println("Exception :"+e);    }
    Thanks in Advance ,
    Keerthi

    Thanks so Much for the quick response .
    Exception Details.
    oracle.apps.fnd.framework.OAException: java.lang.ClassCastException at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:888) at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(OAPageErrorHandler.java:1145) at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(OAPageErrorHandler.java:1408) at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2637) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418) at OA.jspService(OA.jsp:40) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803) at java.lang.Thread.run(Thread.java:534) ## Detail 0 ## java.lang.ClassCastException at SONY.oracle.apps.inv.xx_slapg.webui.ServiceRequestCO.processFormRequest(ServiceRequestCO.java:153) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:799) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1118) at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363) at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2633) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418) at OA.jspService(OA.jsp:40) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803) at java.lang.Thread.run(Thread.java:534) java.lang.ClassCastException at SONY.oracle.apps.inv.xx_slapg.webui.ServiceRequestCO.processFormRequest(ServiceRequestCO.java:153) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:799) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1118) at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363) at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2633) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418) at OA.jspService(OA.jsp:40) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803) at java.lang.Thread.run(Thread.java:534)
    Here is my code .
    java.util.Date StartDate=(java.util.Date)row.getAttribute("StartDate");
    ------------------------------------------------------------------------------------------------

  • I can't  cast  java.util.Date to  oracle.jbo.domain.Date

    Hi, i have a variable "pippo" type java.util.Date formatted like (dd-MM-YYYY hh:mm:ss)
    and I want insert in my Database where the field is Date type(oracle.jbo.domain.Date)
    in the same format(dd-MM-YYYY hh:mm:ss).
    I try to convert "pippo" but the result is formatted(dd-MM-YYYY hh:mm:ss).
    Thank's a lot yours time and i'm very sorry for my easy english
    Bye Luca

    Here is what i have seen that works , but does not preserve milliseconds. Does anyone have other solution? Using dateValue() looses hours, mins and seconds.
    public oracle.jbo.domain.Date toJboDate(java.util.Date pJavaDate)
    return new oracle.jbo.domain.Date(new Timestamp(pJavaDate.getTime()));
    public java.util.Date toJavaDate(oracle.jbo.domain.Date pJboDate)
    return new Date(pJboDate.timestampValue().getTime());
    Chandresh

  • Conversion from timestamp to date

    Hi All,
    Does anyone know how to convert a timestamp value to a date???
    Any help is appreciated

    I want to send the value as a date. This is because
    in other .java file i accept this value as
    java.sql.Date as a parameterWhy do you have java.sql.Timestamp objects then?
    Why not directly getting java.sql.Date object from database?
    Why do your java classes use java.sql.Date instead of java.util.Date?

  • Why won't my Set Dynaminc Data Attributes timestamp my data

    Using LabView 2011. Built a program that uses a DAQ Assistant to read some sensors. Output is a Dynamic Data Array. Using the Write to Measurement File Express vi to log the data. Set the X Value (time) Columns to One Column only. Result: I get the dt value in the X Value column. How do I get it to display the timestamp instead?
    I have tried inserting a Set Attributes express vi between the DAQ Assistant and the Write to Measurement file and selected Start timestamp. No effect. Selected Timestamp under signal index. Nope. That didn't work. Tried setting them both. Still no luck.
    Any assistance would be appreciated.
    Thanks in advanced,
    Dean

    You are NOT going to belive this. After spending the afternoon writing VIs for handling existing filenames and exporting waveforms to spreadshet files, I start mucking around with the string because it is putting a blank line between the DAQ reads (5 rows for 5 samples, then a blank row and then the acquisition loops again). In the process of testing (removing the extra carriage returns in the string) I start getting Excel files that no longer have the date or hour, just the minutes and seconds. Wt?
    Turns out, Excel sometimes does that. Format the cells using the custom feature and chose dd/mm/yyyy hh:mm:ss.00 and suddenly its all back to normal.
    To add to my frustration I went back to the original data file my student was complaining about and formatted the cells and guess what? The standard express vi's export the date, hour, minutes, seconds. All you have to do is use the custom cell format in excel.
    However, the standard express vis will still drop those stupid blank rows in your data.
    Thanks for your assistance Dennis. I hope my frustrations as noted above will be of some use to you in the future.
    Best regards,
    Dean

  • Timestamp to date format SQL

    hi there,
    I was getting data in this format
    0x00000000004890D4
    0x0000000000489121
    0x0000000000480004
    I want to convert this to proper date format ......
    is there any Query to convert this to date format in SQL ? Can anyone guide me please

    timestamp is just an automatically bumped sequential number, it is not datetime.
    BOL: " timestamp is a  data type that exposes automatically generated binary numbers, which are guaranteed to be unique within a database.
    timestamp is used typically as a mechanism for version-stamping table rows. The storage size is 8 bytes.
    Remarks
    The Transact-SQL timestamp data type is not the same as the
    timestamp data type defined in the SQL-92 standard. The SQL-92 timestamp data type is equivalent to the Transact-SQL
    datetime data type. "
    http://technet.microsoft.com/en-us/library/aa260631(v=sql.80).aspx
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Convert from timestamp to date in a table

    Hi All,
    I have a table in oracle 10g r2.
    I want to convert from time-stamp to date in a column of my table.
    The table contain 10 million records.Please help me out with the easiest way to proceed.
    Thanks in advance
    USR0072

    Add a date column to the table
    run an UPDATE statement to update the date column from the timestamp column
    mark the timestamp column unused (or drop the column)

  • Analytic View join issue between TIMESTAMP and DATE formats

    I have a fact table in my data foundation that has a TIMESTAMP date that i am trying to join with to my calendar table that has  a DATE format .  I am unable to query this view after creating it and it appears to be because of the data type differences.  Is there a way to convert when joining? i can not seem to find a way to do this

    Yes, you can use a generated always statement to create a join predicate and join against that in the view.
    Or you can join against the M_TIME_DIMENSION table in an attribute view to convert.
    Or you can create a calculated column and do a union.
    Depending on the requirements, one of these will be the best fit.

Maybe you are looking for

  • HTML Templates in integrated ITS

    Hi, I am using certain ITS services in integrated ITS. However, their look and feel is like WebGUI. For two of the services, there are HTML templates defined but still their look and feel is like WebGUI. If I do not definr ~GENERATEDYNPRO = 1, then I

  • Migrating forms/reports 6i to 11g

    Hi, Im looking for a step-by-step guide to migrate from form/reports 6i to forms 11g. I found the document bellow. Can one suggest more resources ? Oracle® Forms Upgrading Oracle Forms 6i to Oracle Forms 11g 11g Release 1 (11.1.1) E10394-01Thanks

  • Can not video chat or audio chat

    I can not video or audio chat with iChat, but it works for skype. this is the error message that I get. Date/Time: 2009-01-25 23:30:26.080 -0600 OS Version: 10.5.6 (Build 9G55) Report Version: 4 iChat Connection Log: 2009-01-25 23:29:26 -0600: AVChat

  • Wbs Vs Internal Order

    Hi Gurus, I'd like to kow which are the advantages of using WBS vs I.O for tracking the expenses related to dicounts in/off invoices. Award points for any helpful suggestion Regards C*

  • Multiple Delimiters from a Text File

    I am having an issue trying to figure out how to seperate this text file into 4 columns so I can use the data, S, 0, { }, {a, d} a, 7, {S}, b, 5, {a}, {c, h} c, 2, {b, d}, {f} d, 10, {S}, {c, e} e, 1, {d}, {f} f, 3, {c, e, h}, {g} g, 4, {f}, {F} h, 4