Timestamp queries

hi -
i have an oracle table with a date(7) field
populated with dates that display as dd-mmm-yy (e.g. 23-OCT-02)
when i attempt to query the database and retrieve the value as a java.sql.Timestamp object it is returned in the following format
2-10-23 00:00:00
If i use the getYear method it returns a -1890 as the year????
All i want to do is query the table for rows between date ranges
Any Ideas? thanks

As getYear is a deprecated method
you can get the range by the following code:
java.util.Calendar cal = java.util.Calendar.getInstance();
     cal.set(1970,0,0);
     java.sql.Timestamp afterTimeStamp = new java.sql.Timestamp( cal.getTime().getTime());
     cal.set(1999,0,0);
     java.sql.Timestamp beforeTimeStamp = new java.sql.Timestamp( cal.getTime().getTime());
     if(dbTimeStamp.before(beforeTimeStamp) && dbTimeStamp.after(afterTimeStamp)){
      //doSomething.
     }

Similar Messages

  • Queries involving where clause with timestamp data type

    I need to use milliseconds in my tables and do queries where I compare the time in the table to a specific time. I changed the column to the TIMESTAMP data type (from DATE) to accommodate the milliseconds.
    I am accessing the data via a C++ program using ODBC to access the Oracle 10g XE database and a SQLBindParameter statement to set up the comparisons.
    Below is a table that looks like mine but simplified to just a few fields:
    . DATA_ID NOT NULL NUMBER(10)
    . START_TIME NOT NULL TIMESTAMP(6)
    . STOP_TIME NOT NULL TIMESTAMP(6)
    My query is:
    . string sql("select "\
    . "to_Char(rv.start_time, 'YYYYMMDD HH24:MI:SS.FF3'), "\
    . "to_Char(rv.stop_time, 'YYYYMMDD HH24:MI:SS.FF3'), "\
    . "rv.data_id "\
    . "from "\
    . "Reservation rv "\
    . "where "\
    . "rv.data_id = ? and "\
    . "rv.stop_time >= to_timestamp(?, 'YYYYMMDD HH24:MI:SS.FF3') and "\
    . "rv.start_time <= to_timestamp(?, 'YYYYMMDD HH24:MI:SS.FF3');");
    MY C++ code (minus the usual statement preparation material) is:
    . string startTime("20090826 15:42:02.000");
    . string stopTime("20110828 02:04:52.000");
    . SQLRETURN rc = SQL_SUCCESS;
    . SQLINTEGER sqlRsrcInstanceId = resource->getResourceInstanceId();
    . SQLLEN sqlRsrcInstanceIdLI = 0;
    . rc |= SQLBindParameter( stmtHandle, 1, SQL_PARAM_INPUT,
    . SQL_C_LONG, SQL_INTEGER, 0, 0,
    . &sqlRsrcInstanceId, 0, &sqlRsrcInstanceIdLI );
    . SQLCHAR sqlStartTime[24];
    . memset(sqlStartTime, 0, 24);
    . SQLLEN sqlStartTimeLI = SQL_NTS;
    . strncpy( (char*)sqlStartTime, startTime, 23);
    . rc |= SQLBindParameter( stmtHandle, 2, SQL_PARAM_INPUT,
    . SQL_C_CHAR, SQL_CHAR,
    . sizeof(sqlStartTime)-1, 0,
    . &sqlStartTime, sizeof(sqlStartTime)-1,
    . &sqlStartTimeLI);
    . SQLCHAR sqlStopTime[24];
    . memset(sqlStopTime, 0, 24);
    . SQLLEN sqlStopTimeLI = SQL_NTS;
    . strncpy( (char*)sqlStopTime, stopTime, 23);
    . rc |= SQLBindParameter( stmtHandle, 3, SQL_PARAM_INPUT,
    . SQL_C_CHAR, SQL_CHAR,
    . sizeof(sqlStopTime)-1, 0,
    . &sqlStopTime, sizeof(sqlStopTime)-1,
    . &sqlStopTimeLI);
    When the statement is executed, I get the following error:
    . ODBC Return Code: SQL Error.
    . Native Error Code/Message:
    . 932/[Oracle][ODBC][Ora]ORA-00932: inconsistent datatypes: expected - got -
    Any suggestions on what is wrong or a better way to perform the query?

    The only way to test a query is to get out of your environment and fire up SQL*Plus (command line).
    I can not read all of what you wrote but the error you are generating should show up there along with sufficient information to quickly fix it.
    Once you have working statement put it back into your environment.

  • Considering current timestamp while running queries

    Hi,
    We have designed an extract query on Oracle Database which picks up all the changes happened from 2 AM (for eg. last_update_date> 10/24/2007 2 AM ).
    Let us assume that the SQL script runs @ 7 AM Everyday and takes approximately 30 minutes.
    We are trying to find out whether this script will consider the changes between 2 AM till 7 AM or 2 AM till 7:30 AM. Any inputs in this regards will be greatly appreciated.
    Thanks,
    Krishna

    Without seeing the script it is impossible to answer your question.
    If you do not understand Oracle's multi-version read consistency model then you need to go to http://tahiti.oracle.com and look read the basic concepts and architecture docs. MVCC (multiversioning) would lead to one answer but without seeing what you are doing it is impossible to know what you've done.

  • How to create a default value of timestamp column?

    I am trying to create a table with a default value on a timestamp column, can it be done?
    CREATE TABLE myTbl
    FutureDateTime date default TIMESTAMP WITH TIME ZONE '2999-12-31 23:23:59.000'
    )

    user1035690 wrote:
    I am trying to create a table with a default value on a timestamp column, can it be done?
    CREATE TABLE myTbl
    FutureDateTime date default TIMESTAMP WITH TIME ZONE '2999-12-31 23:23:59.000'
    )Yes, but you don't have a timestamp column, you have a date column.
    CREATE TABLE myTbl
       FutureDateTime date default to_date('2999-12-31 23:23:59', 'yyyy-mm-dd hh24:mi:ss')
      4  );
    Table created.
    Elapsed: 00:00:00.09
    ME_XE?And just in case you weren't aware, storing "end of time" information like this will be rough on your queries (it skewes the cost based optimizers estimates for cardinalities and could wildly throw off the estimates for your queries, resulting in bad plans). You're better off to store NULL values, NULL denoting not known values.
    Just an FYI :)

  • Unused queries & Technical Content

    Hi folks,
    I need to find out the unused queries (e.g. the ones that weren't used in last 13 months). As far as I know the best way is to use the technical content (0BWTC_C10); but unfortunately it's not active in our system at the moment.
    Another option is, using the "Last Used" field of RSZCOMPDIR. We have another "but" here. I've figured out that this field is updated even though a query is opened in query designer.
    My questions are:
    1. Any ideas for defining such queries in this situation?
    2. What are the disadvantages of using this technical content? (I mean the extra work load at server-side.)
    Thanks.

    hi pekcan,
    you can run transaction rszdelete to get a list of all queries not used for a defined time.
    Unused/unnecessary Queries can lead to higher times in the 'Open' &#56256;&#56526; 'Query' dialog. They also cause an unnecessary allocation of disk space.
    Check regularly whether queries are really still in use. The 'Last Used' field in transaction RSZDELETE (Delete Objects) is related to table RSZCOMPDIR. 'Last Used' is updated in table RSZCOMPDIR with the exact timestamp of when queries are executed with the BEx Analyzer or Web Frontend.
    to get some idea regarding technical content, use the links.
    http://help.sap.com/saphelp_nw70/helpdata/en/f2/e81c3b85e6e939e10000000a11402f/frameset.htm
    with hopes,
    Raja singh

  • How can I create an index on the date part of a timestamp field?

    is there a way I can create an index on the date part of a timestamp field?

    LONGENECKER wrote:
    Idea:
    If you find no direct command that allows you to create an index on JUST the date portion of a timestamp datatype column then I recommend you consider splitting date and time into two seperate columns.
    If date is column "A" and time is column "B" then you can concatenate them using a view or virtual column (in 11G) to re-assemble them at run time.
    In the solution I describe above you might trade ease of management for better performing queries.
    Additional Info:
    This thread may be of some value.
    Can we create INDEX on TIMESTAMP column???
    And what datatype do you propose for your columns A and B? The only proper datatypes would be DATE or TIMESTAMP. Both of these inherently carry both date and time components, so that would have to be dealt with anyway. The use of any character or number datatype to hold date and/or time should be treated with an application of Billy's lead pipe.
    Perhaps function based indexes would be a better solution.

  • CS5 has stopped working pop up everytime when selecting fonts. details:  Problem signature:   Problem Event Name:APPCRASH   Application Name:Illustrator.exe   Application Version:15.1.0.39   Application Timestamp:4d76c9e3   Fault Module Name:CoolType.dll

    Stops responding, etc
    details
    Problem signature:
      Problem Event Name:    APPCRASH
      Application Name:    Illustrator.exe
      Application Version:    15.1.0.39
      Application Timestamp:    4d76c9e3
      Fault Module Name:    CoolType.dll
      Fault Module Version:    5.7.83.9418
      Fault Module Timestamp:    4c296b69
      Exception Code:    c0000005
      Exception Offset:    00021ae1
      OS Version:    6.1.7601.2.1.0.768.3
      Locale ID:    1033
      Additional Information 1:    8e1b
      Additional Information 2:    8e1b636bd3438ac15d03ef1549553b25
      Additional Information 3:    1b31
      Additional Information 4:    1b316dab8b65bf468124c367b4a50e14

    But I am assuming that when I make the installer, the 32-bit Run Time Engine is appened with the installer, as show below
    Since from the picture you can see its including the support installers from '\Program Files (x86)\'
    The application runs queries to fetch data from database in SQL server 2008, and for that I am using a Microsoft SQL Native Client 2008 R2 64 bit ( this is the only version that installs on either PC, even the one on which I developed my LV Application).
    I am not using any driver, only toolkits for reports - and for that I un-checked the "Remove unused polymorphic VI instances" when making the executable, otherwise LV throws up an exception that share variable are not being included.
    Yes I did reboot every time after I ran the installation.
    Still getting the same error.

  • Migrating Sybase "timestamp" data type to Oracle DB

    Hi,
    We are migrating huge Application currently running on Sybase database
    to Oracle 10.2.0.3 (500+ Tables and Stored Procedures).
    Have following questions regarding this Migration.
    1) Many of the Sybase Tables have column which is of Sybase data type "timestamp".
    Do you have any recommendation what is the data type to be used in Oracle for
    migrating "timestamp" data type in Sybase?
    2) How should we migrate existing data and business logic residing in Sybase for
    data columns of Sybase data type "timestamp" ?
    Given below are details on how we use Sybase timestamp Column in our Application
    and we are trying to arrive at the best Solution that is possible for migrating
    all those Tables and related business logic to Oracle.
    We have following Control Table in Sybase which has column of timestamp data type and
    some other Business keys.
    sp_help EQP_IES_CRE_TIMESTAMP (This is similar to desc <table> command in Oracle)
    EQP_IES_CRE_TIMESTAMP,dbo,user table
    default,Nov 14 2001 10:39AM
    CRE_TIMESTAMP ,timestamp,8,,,0,,,,0
    REF_NUM ,char,30,,,0,,,,0
    REC_UPD_DT ,datetime,8,,,1,,,,0
    EQP_IES_CRE_TIMESTAMPI1,clustered, unique located on default, CRE_TIMESTAMP, REF_NUM, REC_UPD_DT,0,0,0,
    Following is the overall logic used in Sybase
    -- Step 1: Based on Event, populate Control Table with new Row.
    -- CRE_TIMESTAMP timestamp Column gets auto-populated by Sybase
    insert EQP_IES_CRE_TIMESTAMP (REF_NUM, REC_UPD_DT)
    values (@uuid_ref_num, @event_cre_dt)
    Since CRE_TIMESTAMP is auto-populated, it does not appear in above INSERT statement.
    -- Step 2: Store timestamp value populated by Sybase in previous step,
    -- to variable @event_timestamp. This value would be referenced
    -- later in other SQL statements
    select @event_timestamp = CRE_TIMESTAMP
    from EQP_IES_CRE_TIMESTAMP
    where REF_NUM = @uuid_ref_num
    and REC_UPD_DT = @event_cre_dt
    -- Sample value for @event_timestamp could be '001c0000182f2089'
    -- It is not very readable or understandable
    -- Step 3: Delete Control Table entry made in Step 1
    delete EQP_IES_CRE_TIMESTAMP from EQP_IES_CRE_TIMESTAMP
    where CRE_TIMESTAMP = @event_timestamp
    -- Step 4: Make use of saved timestamp value from Step 2 to trigger queries
    -- against other Tables that have timestamp Columns
    -- Some sample queries are as shown below
    delete eqp_staging
    where event_timestamp > @event_timestamp;
    insert into eqp_movement values(@event_timestamp, ......other columns) ;
    Any idea how above Table and logic could be migrated to Oracle DB
    We would also like to know how data values that currently exist
    in Sybase Tables should be populated in Oracle .
    Any suggestions or tips would be greatly appreciated
    Thanks
    Auroprem

    Hi All,
    Thanks for your responses.
    We have decided on Solution to migrate "timestamp" Column from Sybase to Oracle, that is
    specific to our Application needs.
    Following is what we decided:
    1) Create RAW Column in Oracle which would contain data Replicated from Sybase "timestamp" Column as is.
    2) Create additional Column of INTEGER data type to store number equivalent of Sybase "timestamp" column
    which would be more usable and consummable in Oracle as compared to RAW datatype.
    3) Write Row-Level INSERT/UPDATE Trigger on migrated Oracle Table to populate INTEGER Column using
    SQL Function TO_NUMBER(<raw_column_value>, 'xxxxxxxx').
    4) Applications that access this Table, upon migration to Oracle, will now start referencing INTEGER Column
    newly defined, and populated via Trigger.
    Please let us know if you see any issues with this approach
    Thanks
    user641521

  • Timestamp error with IR 9.3 and CSV Files

    Hi all, I'm new to this forum and getting used to all of the Hyperion functionalities. I'm trying to create a query that will give me the history of orders and for that I'm using CSV files as the source of information. I have date fields that when I select them returns me a formatting error: "12/18/2009 doesn't match date format: 1992-01-31 00:00:00". I assume that this is because the field format is recognized as Timestamp. Is there a way to change the field format from within Hyperion?
    Appreciate your help!

    How and where exactly did you make this modification? I moved from an old PC to a new one and my queries work great on my old PC but with my new one, I am getting this "doesn't match date format:" error. I didn't have to make any changes when I set things up on my old PC (at least not that I remember) and not sure what to do here. Any help would be greatly appreciated.

  • Timestamp conversion error in BPEL

    My BPEL process queries a date Column using sql query and inserts the data into the timestamp column of a table.
    I am getting following error in the BPEL process.
    insert failed. Descriptor name: InsertEdrmsRetentionUpdates.EdrmsRetentionupdates. Caused by: Unparseable date: "2009-10-20 10:13:25.000"
    Caused by Exception TOPLINK-3001 (Oracle TopLink - 10g Release 3 (10.1.3.4.0) (Build 080602)): oracle.toplink.exceptions.ConversionException
    Exception Description: The object xs:datetime 2009-10-20 10:13:25.0, of class class java.lang.String, could not be converted to class java.sql.Timestamp.
    Internal Exception: java.text.ParseException: Unparseable date: "2009-10-20 10:13:25.000".
    What is going wrong?
    Please help its very urgent..
    Thanks,
    Prasanna

    Fixed..
    Datatype of the Date Column in the DBAdapter for sql query was String.
    I changed it to xs:dateTime manually and it worked.
    --Prasanna                                                                                                                                                                                                                                                                                                       

  • [iOS4] CMDeviceMotion and timestamp problem

    Hi,
    Excuse my English as it isn't my primary language.
    I hava a problem using an instance of CMDeviceMotion. I need data from both the gyro and accelerometer and the frequency of sample is set at the maximum, 100.
    I also need the timestamp at which the sample was taken. However, at the beginning the timestamp doesn't change even if the acceleration and gyro change. I got something like that :
    0.003779 -0.050910 0.001185 933.604339
    0.035029 -0.042457 0.019893 933.604339
    0.062266 -0.009147 0.084819 933.604339
    0.069300 0.012292 0.092631 933.604339
    0.047862 0.018517 0.091456 933.604339
    0.035304 0.029885 0.084575 933.604339
    0.032496 0.039498 0.083583 933.604339
    We have acceleration.x, .y, .z and the timestamp. As you can see the timestamp doesn't change for about 60 upgrades ~6 seconds.
    Besides, when it finally starts upgrading, it sometimes sample twice the accelreation/gyro at the same timestamp :
    0.115215 0.005342 -0.051157 1385.964002
    *0.120561 0.019797 -0.054112 1385.977830*
    *0.122637 0.031470 -0.051182 1385.977830*
    0.113840 0.042271 -0.045493 1385.992829
    Here is my code :
    In the viewDidLoad method :
    motionManager = [[CMMotionManager alloc] init];
    motionManager.deviceMotionUpdateInterval = 0.01;
    frequence = 100;
    Then I have a method invoked by a button :
    [motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue]
    withHandler: ^(CMDeviceMotion *motionData, NSError *error)
    CMRotationRate rotation = motionData.rotationRate;
    CMAcceleration acceleration = motionData.userAcceleration;
    NSLog(@"rotation rate = [%f, %f, %f, %f]", rotation.x, rotation.y, rotation.z, motionData.timestamp);
    NSLog(@"acceleration rate = [%f, %f, %f, %f]", acceleration.x, acceleration.y, acceleration.z, motionData.timestamp);
    Any help appreciated,
    Thanks for your time
    Loïs

    Oracle FAQ page: http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#08_01
    Well obviously that was really stupid.
    I'm adding some queries to an older part of our code base and while reading through the documentation for one of the classes I found that we weren't using our normal Hibernate queries because we needed to ensure that we weren't sending Timestamps to Oracle. Apparently the Timestamp would be converted to a Date because the column in the database was of type DATE. This was causing problems because the DATE column's index was being ignored and the table contains millions of records.
    Not sure I follow that logic.
    If the value was going into the database then it would update the index.
    From that only one of the following could be true.
    1. It wasn't going into the database.
    2. It was being truncated to a date.
    The Oracle FAQ seems to indicate that this has been fixed in the 11.1 JDBC drivers. I know that I can use 11.1 JDBC drivers with a 10.2.0 database, but will it use the new 11.1 mappings for DATE and TIMESTAMP or the old 10.2.0 mappings? I would agree with your interpretation of the FAQ.
    And I would then follow it up by testing both with the old driver and the new.

  • TIMESTAMP values are not displayed properly

    I'm using eclipse 3.3.2, dtp 1.5.2 with oracle dtp plugin. When I ran command 'create table test1(aa timestamp(6))' and then open table I've found that 'aa' column type is displayed as VARCHAR2. All queries for timestamps return something like 'oracle.sql.TIMESTAMP@12312'. Anybody knows how to fix this?

    Hi,
    Go to SE63 and Translate your form in your desired language 'SA'.
    In SE63> Go to Translation>abap objects>other long text>chose Smartforms & Styles.
    Save & Activate it. It will definitely come.
    Thnaks,
    Abhijit

  • How to get modification timestamp of user in GAL

    Hi,
    Sorry for bothering you but I have one more question.
    In general I have performance issue. I am downloading users from GAL with all details and it takes about 3h. GAL has about 17000 users. I didn't found any solution to make it faster.
    But in next sync I would like to get data only for modified users but I don't know how to do it efficiently.
    Now I will describe more details.
    <pseudocode>
    Foreach( var addressEntry in Application.Session.AddressLists[…].AddressEntries)
    Var eu = addressEntry.GetExchangeUser()
    Var props = addressEntry.PropertyAccessor.GetProperties(…)
    LocalDb.SaveContact(addressentry, eu, props)
    The most time expensive part is :
    addressEntry.PropertyAccessor.GetProperties(…)
    ,it takes 2,5h. I would like in next “Download Process” download only modified entires but I don’t know how to get the timestamp efficiently. The timestamp is available using this:
    addressEntry.PropertyAccessor.GetProperty(“http://schemas.microsoft.com/mapi/proptag/0x30080040“)
    , but this is as slow as
    addressEntry.PropertyAccessor.GetProperties(…)
    , so there is no sense to check the timestamp and if it is old ask for properties.
    Can I get the timestamp information in other way, more efficiently?

    Mots address book providers (GAL included) are not very good with restrictions.
    GAL address book provider does not really do anything that you cannot do through the Active Directory interfaces. You should be able to run AD queries that use the "last modified  time" attribute.
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

  • How to sync the timestamp type in 10g with oracle 8i

    Hi,
    I have oracle 8i on solaris server and we have created application database as well.
    I have created oracle 10g databse in some other server and imported the whole database into 10g.
    Since there is timestamp format difference in oracle 8i and 10g the application is not working properly in 10g server.
    see the below example
    In 8i
    select to_char(sys.standard.sys_at_time_zone(sys.standard.localtimestamp,'0:00')) from dual
    22-MAY-09 09.59.50 AM +00:00
    In 10g
    select to_char(sys.standard.sys_at_time_zone(sys.standard.localtimestamp,'0:00')) from dual
    22-MAY-09 09.53.54.638090000 AM +00:00
    since in 10g it is giving microseconds as well in the output unlike 8i, our application is not working properly.
    Please advice
    RB

    Does setting NLS_TIMESTAMP_TZ_FORMAT at session level (using logon trigger) solve your problem?
    BTW, this does not qualify as an installation issue so please post such queries in Database-General forum.

  • Obtain all list of queries run on the database in history.

    Good day to all of you.
    This is my first post here.
    We have an application where we need to study the set of all queries that were run successfully on the DB by users of that db.
    In particular, SELECT stats that were run on the DB Tables/Views...
    Therefore, does Oracle have a 'Query History' of some sort where SQL statements are stored in archives or something like that?
    If so, for how many days of data does it store ?
    Is the DBA_HIST_SQLTEXT View useful ? I took a look at it, however, it did not seem to store any of the queries that were run
    by users. It had some DML statements that i am sure were not run by any of the users.
    Any help in this regard would be greatly appreciated as this is central to what we wish to implement in the future.
    Thank you.
    Karan.

    welcome to forum,
    please refer the links:- it may be useful to you.
    Timestamp from DBA_HIST_SQLTEXT
    http://www.dba-oracle.com/t_time_series_sql_performance_tracking.htm

Maybe you are looking for