Trying to compare date columns with differing formats...

I have an app that created a series of tables via ODBC using ANSI standard datatypes. For most, this isn't a problem, but one in particular is driving me crazy: TIMESTAMP. In Oracle, it shows up as a TIMESTAMP(6). I don't want to mess with the app's tables, so every time there is an insert to their tables, I have a trigger which creates records in corresponding tables I build using standard Oracle datatypes (DATE).
I have one function that gets called by several of the triggers that retrieves me a specific row to update, and it uses the value from this TIMESTAMP field in the WHERE clause like this (the value is passed into the function as a parmeter):
SELECT TIMECARD_ID INTO tc_id FROM TS_TIMECARD_MAIN
WHERE EMP_ID = e_id AND VEHICLE_ID = v_id
AND IN_TIME <= logout AND OUT_TIME IS NULL; <----
I seem to have a formatting issue, because unless the "logout" date is a full day later than IN_TIME, it doesn't pull the record (my code does a check to verify there is only one record matching the criteria but I haven't posted it all here for simplicity). I need it to be able to select the correct record with a one second difference.
I have NLS_TIMESTAMP_FORMAT set to 'YYYY-MM-DD HH24.MI.SS.FF' and NLS_DATE_FORMAT set to 'YYYY-MM-DD HH24:MI:SS'. The relevant describes are included below. Can anyone suggest how to format my query (I expect to use the TO_DATE and TO_CHAR to compensate, but haven't found the right set) so that it resolves properly? Date math is a pain, but it is critical to my purposes.
Vendor's table
FIELD3_DATETIME TIMESTAMP(6)
My table
TIMECARD_ID NOT NULL NUMBER(10)
EMP_ID NOT NULL NUMBER(10)
IN_TIME DATE
OUT_TIME DATE
VEHICLE_ID NUMBER(10)
Also, some sample default output from each table - not sure why formatting is wierd on my table.
Vendor's table
UNIQKEY STATUS FORM_ID VEHICLE_NUMBER CREATED_DATETIME
11515780978071234994451 0 21423 24005 28-JUN-06 05.10.14.000000 PM
CHECK_DVIR NEW_DVIR SERVICEABLE DETAILS
1 1 1 everything ok
INSPECTION_TIME ODOMETER LATITUDE LONGITUDE
28-JUN-06 05.12.12.000000 PM 119885.1 44.7889490425587 -95.2167677879333
My table
TIMECARD_ID EMP_ID IN_TIME OUT_TIME VEHICLE_ID
5 20044 28-JUN-06 24005

That sounds a bit complicated. If you post your query I'm sure there will be a simpler approach, perhaps something like
where  date_timestamp between cast(sysdate -30 as timestamp) and systimestampor if you prefer
where  date_timestamp between systimestamp - interval '30' day and systimestampas discussed on Re: convert timestamp to date.

Similar Messages

  • Comparing two numbers with different formats

    Dear Java developers
    I am trying to compare two numbers but they have different formats. long x = 8981261369, Object obj = "8,981,261,369".
    I am trying to see if this two values are equal which is the case in the example above except one has a thousand separator but not sure how to do that.
    How can I lose the thousand separator and just compare them as two long values.
    Your input will be much appreciated
    Thanks

    iu433 wrote:
    I need a generic way of doing this. Because sometimes the Object does not have a thousand separator. Can i use some kind of NumberFormat to do this.You'll need to know what formats the string (not the number--as already mentioned, numbers don't have formats) can have, and then try them one by one.
    Of course, there can be some ambiguity. Does "123,456" represent one hundred twenty three thousand four hundred fifty six, or is that comma a decimal separator, and it represents one hundred twenty three and four hundred fifty six thousandths?
    The point is, you have to have a clear definition of what formats are allowed and how to determine which one it is. There's no magic way for Java to do that for you.

  • "System error: Move error" on comparing DATE rows with literal timestamps

    say, I have a table consisting of a DATE and a TIMESTAMP column:
      create table test (
      d date,
      ts timestamp
    now the problem:
    when I try to retrieve values using a statement like this (using MaxDB's SQL Studio or via JDBC):
      select * from test
      where  d >= {ts '2007-06-18 12:19:45'}
    it produces the following error:
      General error;-9111 POS(36) System error: Move error
    So, I am not able to compare DATE columns with timestamp values?
    In contrast, the following combinations all work flawlessly:
      select * from test
      where  d >= {ts '2007-06-18 12:19:45'}
      select * from test
      where ts >= {d '2007-06-18'}
      select * from test
      where  ts >= {ts '2007-06-18 12:19:45'}
    Thus, the opposite direction (comparing a TIMESTAMP column to a literal date value) apparently poses no problem to the MaxDB database engine.
    Unfortunately, I cannot just resort to "truncating" the timestamp values and using the {d ...}-Syntax, because I am using Apache's Torque object-relational mapper which generates the statement like this and feeds the JDBC API with it. Anyway, I deem this a bug in MaxDB, especially with respect to the quite obscure error message.
    I can reproduce this issue on both MaxDB 7.5 and 7.6 server, using client software (SQL Studio), version 7.5 and 7.6 as well.
    Does anybody know this problem?
    TIA,
    Alex

    Hi,
    this is a new bug and we will fix it with one of the next versions of MaxDB.
    You can watch the proceeding in our internal bug tracking system:
    http://www.sapdb.org/webpts?wptsdetail=yes&ErrorType=0&ErrorID=1151609
    Thank you for reporting it.
    Kind regards
    Holger

  • Not able to save date column with custom date format. in OBIEE 11g

    Hi,
    I have migrated one report from OBIEE 10g to 11g. There is a date column with customized date format(i.e. Default format is 'dd-MMM-yyyy' and I have used 'MMM-yyyy').
    But when I use this custom format and try to save the report in 11g its giving this below error.
    ''Catalog object privilege validation failed for user to path /shared/ALM BI/Finacial Results/History Income Statement Detail.
    You do not currently have sufficient privileges to save a report or dashboard page that contains HTML markup.
    This HTML might be present in column headings, table headings, text views, narrative views, the print header,
    or the print footer and must be removed before saving.''
    Please let me know what changes I need to do for this.
    Regards,
    Ambika Nanda.

    Hi ,
    privilage issues...check the security settings once..
    Thanks,
    Ananth

  • Date column with format mask 'hh12:mi pm'

    let's say the user input record as shown below :
    trip At01 At02
    1 9:30 AM 12:30 PM
    At02 & At02 are date column with format mask 'hh12:mi pm'. When the user input 9:30 and tab to next item, the column will display as 09:30 AM. Then when user input 12:30 at AT02, it will display as 12:30 PM.
    Anyway, if I enter 1:00 at AT02, it will display as 01:00 AM. Actually I want to display as 01:00 PM. I still can go back to the field to edit it manually but is there a way that I can do as mentioned ?
    Please advise.
    Thanks,
    Shu Wen

    You are going to have to write your own validation logic to do this - You'll have to decide what point AM shoudl be defaulted and what point PM should be used. I don't think that there is a format mask that provides this functionality.

  • SSIS project - read multiple flat files with different formats

    hi all,
    i need to import multiple flat files with different formats into different tables of the sql server database and not able to figure out the best way out in ssis to do so...
    please advise the possible methods in ssis to do so and if possible the process which can be dynamic as file names or columns might change in future.

    Hi AK1987,
    To import flat files with dynamic columns, we can use Script Task inside a Foreach Loop Container to parse the first row of the flat file to get the columns names and save them into a .NET variable, then, we can create “Create Table” script based on this
    variable, and then store the script into a SSIS package variable. After that, we create a staging table based on the package variable, load the flat file data to the staging table. Eventually, we load data from the staging table to the destination table. For
    the detail steps, please walk through the following blog:
    http://www.citagus.com/citagus/blog/importing-from-flat-file-with-dynamic-columns/ 
    Regards,
    Mike Yin
    TechNet Community Support

  • Too many flat files with different formats.

    Hi gurus,
    i have a headache problems. that is follows:
    We will upload data from flat files,but you know there are about 100 .xls files and with different formats.
    and as you know  the datasource of the flat file must correspond to every fields of the flat file.
    but you know there are 100 flat files and if we donot do any optimise,we will create about 100 transformation and 100 datasource to meet our requirements.
    but that seems impossible.
    is there any good idea to decrease the number of transfomation ?

    Hi AK1987,
    To import flat files with dynamic columns, we can use Script Task inside a Foreach Loop Container to parse the first row of the flat file to get the columns names and save them into a .NET variable, then, we can create “Create Table” script based on this
    variable, and then store the script into a SSIS package variable. After that, we create a staging table based on the package variable, load the flat file data to the staging table. Eventually, we load data from the staging table to the destination table. For
    the detail steps, please walk through the following blog:
    http://www.citagus.com/citagus/blog/importing-from-flat-file-with-dynamic-columns/ 
    Regards,
    Mike Yin
    TechNet Community Support

  • How can I setup an .indd with two columns with different threads so that I can export to epub?

    Hi all. Sorry, english is not my native language. I´ve made an .indd: each page has two columns with different threads (is a bilingual text). When I export this .indd to .epub only appears one column from a thread following the next thread. What can i do to fix this? My indesign is CS6
    Thank you

    There are fixed format EPUB files as can be used for children's books, etc. where there are a lot of illustrations. However, those are very work-intensive to produce. I've never worked on one.
    Anne-Marie Concepcion did a Lynda.com video on producing one.
    Rorohiko produces a product called ePubCrawler which can help in produced fixed format EPUB files:
    Fixed Layout EPUB Assistant In InDesign: ePubCrawler | Rorohiko ...

  • Numbers point to a cell with different formatting to create conditional format

    Hi all, not sure if this has been brought up but my search efforts haven't found anything. I know conditional formatting is not supported in IOS numbers but I saw a buddy do a little trick a while ago and I've been trying to replicate it. On his iPad, he created a numbers spreadsheet that had a logic function (=if). And if that function was true it pointed to another cell with different formatting. The result was, the cell would become the same format as the cell it was pointing too. This created the effect of a conditional format in a sense. I can get this to work with limited effect, only if the cell is a "text" cell and not a formula. As well the background colour doesn't get picked up, only the format of the cell text itself. I'm trying to get in touch with him for help but in the mean time does anyone have any experience in this kind of method?
    Cheers

    As an example:
    If A > B, then A-B, otherwise make it equal this other cell (D1 for example)
    {=if(a1>b1,a1-b1,d1)}
    And in that d1 cell I would make another formula that also does the same subtraction (a1-b1) however knowing it will be a negative number this time, I paint the cell bright red and hopefully the original cell will then look the same since it is now equal to this one.
    Unfortunately it looks like this wont work. The closest thing to doing this trick I have found is pointing to a cell formatted as text, such as a blank cell. Then the original cell takes on the formatting characteristics of the text cell.  The problem is the text cell is useless since it can't do any sort of math. I can't even set the cell to simply equal another one and format it as text only. So far it looks like the only conditional type of trickery I can do is make the numbers disappear by pointing to a blank text cell.
    I hope that helps describe it a little better.

  • Can we Compare PDF Output with CSV format

    Team,
    Can we Compare PDF Output with CSV format.
    In Excel I need to two text boxes asking us to browse the files and compare the files PDF & CSV format.
    Please suggest me if we have solution for this.
    Thanks!
    Kiran

    Hi
    I'm afraid the Excel Application does not support this function currently, I am suggesting you to take advantage of a third party component to achieve this goal.
    Thanks for your understanding.
    Best Regards
    Lan
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • One Key FIgure in more than one column with different restrictions

    Hi,
      I am using a key figure in more than one column with different restrictions, but restriction in one column is affecting the result in other column. What shall i do to make it independent from one another??

    Hi Pravender Chauhan,
        If you want in Single column different value for different Rows based on same Key Figure, you can create Structure where you can define different logic for each row but using same key figure.
    If you want to use different Key figures then you should have to Restricted Key Figure and for any calculation you can use calculated Key figure.
    Assign points if Useful.
    Regards,
    Rajdeep.

  • Data Associtions not enabling  while i am  trying to do data mapping with data Associtions in BPM studio what is the reson?

    Data Associtions not enabling  while i am  trying to do data mapping with data Associtions in BPM studio what is the reson?

    Shouldn't @StartDate be an input parameter to the stored procedure? @RunDate also?
    Example for sp with parameters:
    http://www.sqlusa.com/bestpractices2008/stored-procedure-parameters/
    The last error will go away upon a successful sp compile.
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Is it possible to create 2 Date objects with different hashcode.

    Hi,
    I want to create 2 java.util.Date objects with different hashcodes. Is it possible??
    Regards,
    Farooq

    import java.util.Date;
    import java.util.Calendar;
    public class TwoDates {
        public static void main(String[] args) {
            Calendar oneCal = Calendar.getInstance();
            oneCal.set(Calendar.YEAR, 1903);
            Calendar anotherCal = Calendar.getInstance();
            Date oneDate = oneCal.getTime();
            Date anotherDate = anotherCal.getTime();
            System.out.println(oneDate.hashCode() + " " +
                               anotherDate.hashCode());
    -14330615 -825112150

  • Date validation with different formatStrings

    I can change formatString property to show a date in a different format.
    For example, I have DD/MM/YYYY so my date is shown like this: 30/11/1980
    Now, I am entering a date like this: 11/30/1980. Should I be getting an error?
    Thanks

    Hi
    Use Follwing date formatter to format date
    var formatter:DateFormatter = new DateFormatter();
    formatter.formatString = "MM/DD/YYYY";
    var formattedDate:String = new String;
    formattedDate = formatter.format(" "); //Date entered in datepicker
    //Condition to validate date
    if((formatter.error != null && formatter.error == "Invalid value") || null == " ") {
         showAlert(" ");
         return;
    Let me know if any concern
    Thanks,
    Atul ([email protected])

  • JFormattedTextField with different format

    Hi...
    I need a JFormattedTextField with different format.
    I need validate that user can type anybody previous format.
    I have looked several example code in the forum, but none it is successfully for me?
    What do you advise to do? Please with an example is better.
    Thank you

    Hi JayDS.
    I had reviewed your VariableLengthMaskFormatter class.
    I don't know if it's good for me.
    When the user begins to type I don't know the format that he'll use.
    When the JText focus lose then I knew the format that user used.
    What can I do?

Maybe you are looking for

  • WebLogic JMS high memory usage and frequent full GCs

    Hi Team,             We have below set up in production (and all the lower environment). 1. WLS: 10.3.6 (64 bit) 2. Java: HP JDK 1.7.0.06 (64 bit) 3. Two Manage server instances in cluster with one Migratable target 4. one JMS server with Persistence

  • How can I prevent commas from being entered in the zip code field?

    I tried entering the following validation on the Bill To Address field but it did not work. Not sure if it's because the address fields are grouped together. NOT(InStr([<PrimaryBillToPostalCode>], ',') > 0 AND [<PrimaryBillToCountry>] = 'USA')

  • Muse (2014.3) no more transparency working in Safari (8.0.4)

    Hello, since the last update of Muse (2014.3) there is no more transparency working in Safari (8.0.4). In Muse it looks like ever, but If I take a look of the site in Safari, there is no transparency on any pictures. So it is not possible to read the

  • No images in Mac Mail

    I used to be able to see images in Mac Mail. I think it stopped after upgrading to Lion. Now the e-mail looks like this: Instead of this: And yes, I have checked the "display images in remote HTML: Any advice? This has been going on for months! Thank

  • Numeric format

    Hi! As u all know in north America style we write no as 1,234.56 and in Europe we write as 1.234,56 . I have a problem related to this only.... when I  use fbz5 for check printing . and my vendor is belong to europe then in check it will display amou